window.$Request = {
    post: function (url, data, response, type) {
        url = $Utils.getAdminPrefix(url);
        NProgress.start();
        $Request.httpRequest({
            url: url,
            data: data ? data : {},
            type: type ? type : 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                'X-CSRF-TOKEN': ($('meta[name="csrf-token"]').attr('content') ? $('meta[name="csrf-token"]').attr('content') : $(window.parent.document).find('meta[name="csrf-token"]').attr('content'))
            },
            response: function (res, status, header) {
                // console.log(status);
                /*错误码 400*/
                if (status > 399 && status < 500) {
                    NProgress.done();
                    $App.$message({message: '网络请求异常，请稍后再试！', type: 'error'});
                    // window.location = '/404?msg=页面未找到';
                    return false;
                }
                /*错误码 500*/
                else if (status >= 500) {
                    NProgress.done();
                    $App.$message({message: '网络请求异常，请稍后再试！', type: 'error'});
                    return false;
                } else {
                    if (!res) {
                        NProgress.done();
                        $App.$message({message: '网络请求异常，请稍后再试！', type: 'error'});
                        return false;
                    }
                    NProgress.done();
                    response(res);
                }
            }
        })
    },

    postJson: function (url, data, response, type) {
        url = $Utils.getAdminPrefix(url);
        var platform = $('meta[name="framework-platform"]').attr('content');
        NProgress.start();
        $Request.httpJsonRequest({
            url: url,
            data: data ? data : {},
            type: type ? type : 'POST',
            headers: {
                'Request-Source' :platform,
                'Content-Type': 'application/json; charset=UTF-8',
                'X-CSRF-TOKEN': ($('meta[name="csrf-token"]').attr('content') ? $('meta[name="csrf-token"]').attr('content') : $(window.parent.document).find('meta[name="csrf-token"]').attr('content'))
            },
            response: function (res, status, header) {
                // console.log(status);
                /*错误码 400*/
                if (status > 399 && status < 500) {
                    NProgress.done();
                    $App.$message({message: '网络请求异常，请稍后再试！', type: 'error'});
                    // window.location = '/404?msg=页面未找到';
                    return false;
                }
                /*错误码 500*/
                else if (status >= 500) {
                    NProgress.done();
                    $App.$message({message: '网络请求异常，请稍后再试！', type: 'error'});
                    return false;
                } else {
                    if (!res) {
                        NProgress.done();
                        $App.$message({message: '网络请求异常，请稍后再试！', type: 'error'});
                        return false;
                    }
                    NProgress.done();
                    response(res);
                }
            }
        })
    },

    get: function (url, data) {
        url = $Utils.getAdminPrefix(url);
        url = url ? url : window.location.href;

        data = data ? data : {};

        if ($.isEmptyObject(data)) {
            window.location.href = url;
        } else {
            window.location.href = url + '?' + $Request.getQueryString(data);
        }
    },

    open: function (url, data) {
        url = $Utils.getAdminPrefix(url);
        url = url ? url : window.location.href;
        data = data ? data : {};
        if ($.isEmptyObject(data)) {
            window.open(url);
        } else {
            window.open(url + '?' + $Request.getQueryString(data));
        }
    },

    frame: function (url, data, options) {
        url = $Utils.getAdminPrefix(url);
        if (!$.isEmptyObject(data)) {
            url = url + '?' + $Request.getQueryString(data)
        }
        var _s = Object.assign({
            width: (parseInt((document.documentElement.clientWidth / 100) * 55)) + 'px',
            height: (parseInt((document.documentElement.clientHeight / 100) * 77)) + 'px',
            msg: '正在打开页面，请稍后。。。'
        }, options);

        var iframe = document.createElement("iframe");
        iframe.id = $Request.random(12);
        iframe.src = url;
        iframe.width = _s.width;
        iframe.height = _s.height;
        iframe.className = 'va-frame__wrapper_iframe';

        $(".va-frame__wrapper").find('iframe').remove();
        window.$__frameLoading = $App.$loading({
            lock: true,
            text: _s.msg,
            spinner: 'el-icon-loading',
        });

        $(".va-frame__wrapper").append(iframe);

        $(window).resize(function () {
            $("body").find('.va-frame__wrapper_iframe').attr('width', (parseInt((document.documentElement.clientWidth / 100) * 55)) + 'px');
            $("body").find('.va-frame__wrapper_iframe').attr('height', (parseInt((document.documentElement.clientHeight / 100) * 77)) + 'px');
        });
    },

    href: function (url, data) {
        url = $Utils.getAdminPrefix(url);
        url = url ? url : window.location.href;
        data = data ? data : {};
        if ($.isEmptyObject(data)) {
            return url;
        } else {
            return url + '?' + $Request.getQueryString(data);
        }
    },

    load: function (url, data, callback) {
        url = $Utils.getAdminPrefix(url);
        var stateObject = {};
        url = url ? url : window.location.href;
        data = data ? data : {};
        if (!$.isEmptyObject(data)) {
            url = url + '?' + $Request.getQueryString(data);
        }
        $("#app").load(url, null, function (response, status, xhr) {
            if (xhr.status === 404) {
                $App.layouts.loading = false;
                $App.$message({message: '网络请求异常，请稍后再试！', type: 'error'});
                if (typeof callback === 'function') {
                    callback(xhr.status);
                }
            } else if (xhr.status === 500) {
                $App.layouts.loading = false;
                $App.$message({message: '服务器响应错误，请稍后再试！', type: 'error'});
                if (typeof callback === 'function') {
                    callback(xhr.status);
                }
            } else {
                history.pushState(stateObject, '', url);
                if (typeof callback === 'function') {
                    callback(xhr.status);
                }
                $App.layouts.loading = false;
            }
        });
    },

    random: function (length) {
        length = length ? length : 16;
        var result = '';
        for (var i = 0; i < length; i++) {
            result += Math.floor(Math.random() * 16).toString(16);
        }
        return result.toUpperCase();
    },

    httpRequest: function (settings) {
        var _s = Object.assign({
            url: window.location.href,
            type: 'POST',
            dataType: 'json',
            async: true,
            data: null,
            headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
            timeout: 0,
            encrypt: true,
            beforeSend: function (xhr) {

            },
            success: function (result, status, xhr) {

            },
            error: function (xhr, status, error) {
                $App.$message({message: '网络请求异常，请稍后再试！', type: 'error'});
            },

            response: function (xhr, status) {

            }
        }, settings);
        if (!_s.url) {
            _s.url = window.location.href
        }
        // 参数验证
        if (!_s.url || !_s.type || !_s.dataType || !_s.async) {
            $App.$message({message: '网络请求异常，请稍后再试！', type: 'error'});
            return;
        }
        // 创建XMLHttpRequest请求对象
        var xhr = new XMLHttpRequest();

        // 请求开始回调函数
        xhr.addEventListener('loadstart', function (e) {
            _s.beforeSend(xhr);
        });

        // 请求成功回调函数
        xhr.addEventListener('load', function (e) {
            var status = xhr.status;
            if ((status >= 200 && status < 300) || status === 304) {
                var result;
                if (xhr.responseType === 'text') {
                    result = xhr.responseText;
                } else if (xhr.responseType === 'document') {
                    result = xhr.responseXML;
                } else {
                    result = xhr.response;
                }
                _s.success(result, status, xhr);
            } else {
                _s.error(xhr, status, e);
            }
        });

        // 请求结束
        xhr.addEventListener('loadend', function (e) {
            var result;
            if (xhr.responseType === 'text') {
                result = xhr.responseText;
            } else if (xhr.responseType === 'document') {
                result = xhr.responseXML;
            } else {
                result = xhr.response;
            }
            _s.response(result, xhr.status);
        });

        // 请求出错
        xhr.addEventListener('error', function (e) {
            _s.error(xhr, xhr.status, e);
        });

        // 请求超时
        xhr.addEventListener('timeout', function (e) {
            _s.error(xhr, 408, e);
        });

        var useUrlParam = false;
        var sType = _s.type.toUpperCase();
        if (sType === 'GET' || sType === 'DELETE') {
            useUrlParam = true;
            _s.url += $Request.getUrlParam(_s.url, _s.data);
        }
        xhr.open(_s.type, _s.url, _s.async);
        xhr.responseType = _s.dataType;
        var headers_keys = Object.keys(_s.headers);
        // 设置请求头
        headers_keys.forEach(function (value, index, array) {
            xhr.setRequestHeader(value, _s.headers[value]);
        });
        if (_s.async && _s.timeout) {
            xhr.timeout = _s.timeout;
        }

        xhr.send(useUrlParam ? null : $Request.getQueryData(_s.data));
    },

    httpJsonRequest: function (settings) {
        var _s = Object.assign({
            url: window.location.href,
            type: 'POST',
            dataType: 'json',
            async: true,
            data: null,
            headers: {'Content-Type': 'application/json; charset=UTF-8'},
            timeout: 0,
            encrypt: true,
            beforeSend: function (xhr) {

            },
            success: function (result, status, xhr) {

            },
            error: function (xhr, status, error) {
                $App.$message({message: '网络请求异常，请稍后再试！', type: 'error'});
            },

            response: function (xhr, status) {

            }
        }, settings);
        if (!_s.url) {
            _s.url = window.location.href
        }
        // 参数验证
        if (!_s.url || !_s.type || !_s.dataType || !_s.async) {
            $App.$message({message: '网络请求异常，请稍后再试！', type: 'error'});
            return;
        }
        // 创建XMLHttpRequest请求对象
        var xhr = new XMLHttpRequest();

        // 请求开始回调函数
        xhr.addEventListener('loadstart', function (e) {
            _s.beforeSend(xhr);
        });

        // 请求成功回调函数
        xhr.addEventListener('load', function (e) {
            var status = xhr.status;
            if ((status >= 200 && status < 300) || status === 304) {
                var result;
                if (xhr.responseType === 'text') {
                    result = xhr.responseText;
                } else if (xhr.responseType === 'document') {
                    result = xhr.responseXML;
                } else {
                    result = xhr.response;
                }
                _s.success(result, status, xhr);
            } else {
                _s.error(xhr, status, e);
            }
        });

        // 请求结束
        xhr.addEventListener('loadend', function (e) {
            var result;
            if (xhr.responseType === 'text') {
                result = xhr.responseText;
            } else if (xhr.responseType === 'document') {
                result = xhr.responseXML;
            } else {
                result = xhr.response;
            }
            _s.response(result, xhr.status);
        });

        // 请求出错
        xhr.addEventListener('error', function (e) {
            _s.error(xhr, xhr.status, e);
        });

        // 请求超时
        xhr.addEventListener('timeout', function (e) {
            _s.error(xhr, 408, e);
        });

        var useUrlParam = false;
        var sType = _s.type.toUpperCase();
        if (sType === 'GET' || sType === 'DELETE') {
            useUrlParam = true;
            _s.url += $Request.getUrlParam(_s.url, _s.data);
        }
        xhr.open(_s.type, _s.url, _s.async);
        xhr.responseType = _s.dataType;
        var headers_keys = Object.keys(_s.headers);
        // 设置请求头
        headers_keys.forEach(function (value, index, array) {
            xhr.setRequestHeader(value, _s.headers[value]);
        });
        if (_s.async && _s.timeout) {
            xhr.timeout = _s.timeout;
        }
        // xhr.send(useUrlParam ? null : $Request.getQueryData(_s.data));
        xhr.send(useUrlParam ? null : JSON.stringify(_s.data));
    },

    getUrlParam: function (url, data) {
        url = $Utils.getAdminPrefix(url);
        if (!data) {
            return '';
        }
        var paramsStr = data instanceof Object ? $Request.getQueryString(data) : data;
        return (url.indexOf('?') !== -1) ? paramsStr : '?' + paramsStr;
    },

    getQueryData: function (data) {
        if (!data) {
            return null;
        }
        if (typeof data === 'string') {
            return data;
        }
        if (data instanceof FormData) {
            return data;
        }
        return $Request.getQueryString(data);
    },

    getQueryString: function (data) {
        var paramsArr = [];
        if (data instanceof Object) {
            Object.keys(data).forEach(function (key) {
                var val = data[key];
                paramsArr.push(encodeURIComponent(key) + '=' + encodeURIComponent(val));
            });
        }
        return paramsArr.join('&');
    }
};
var $Config = {
    data: function () {
        return {
            isCollapse: false,
        }
    },
    methods: {
        /*主题色右侧菜单事件*/
        themeCommandEvent: function (theme) {
            let root = document.querySelector(":root");
            Cookies.set('theme', theme);
            root.style.setProperty("--themeColors", themeStyle[theme].themeColors);
            root.style.setProperty("--themeTextColors", themeStyle[theme].themeTextColors);
            root.style.setProperty("--themeSelectColors", themeStyle[theme].themeSelectColors);
            root.style.setProperty("--headerBackground", themeStyle[theme].headerBackground);
            root.style.setProperty("--headerTextColors", themeStyle[theme].headerTextColors);
            root.style.setProperty("--leftBackground", themeStyle[theme].leftBackground);
            root.style.setProperty("--leftTextColors", themeStyle[theme].leftTextColors);
            root.style.setProperty("--buttonHoverColors", themeStyle[theme].buttonHoverColors);
        },
        /*左侧菜单展合*/
        menuClose() {
            var that = this;
            if (that.isCollapse === true) {
                that.isCollapse = false;
                $('#app-main').css('--real-sidebar-width', '200px')
                $('.left-title span').css('display', 'inline')
            } else {
                that.isCollapse = true;
                $('#app-main').css('--real-sidebar-width', '64px')
                $('.left-title span').css('display', 'none')
            }
            // 监听窗口大小变化
            that.handleResize()
        },
        handleResize(){
            // 监听窗口开合
        }
    },
    beforeCreate: function () {
    },

    created: function () {
    },

    mounted: function () {
        //设置主体
        var $theme = Cookies.get('theme');
        this.themeCommandEvent($theme ? $theme : 'index');
    }
};
var $Layouts = {
    data: function () {
        return {
            config: {
                menuLayouts: 'left', permissions: true, breadcrumb: true,
                header: {show: false, msg: '详细页面', back: '', callback: ''}, menu_id: 0,
            },
            currentItemsKey:'currentItems',
            layoutsLeftMenuEventKey:'layoutsLeftMenuEvent',
            permissions: [],
            layouts: {

                tabs: {
                    menuOpenIds: [],
                    active: 0,
                    menus: {},
                    show: true,
                    custom: false,
                    openeds: [],
                    headerParentId: 0
                },

                left: {
                    menuOpenIds: [],
                    active: '0',
                    menus: {},
                    show: true,
                    custom: false,
                    openeds: [],
                    headerParentId: 0,
                },

                drawerFormsHeight: {'height': '600px'},
                drawerFixedHeight: {'height': '480px'},
                dialogFormsHeight: {'height': '480px'},
                dialogFixedHeight: {'height': '480px'},
            },
            GalleryParams: {
                models: '',
                action: 'framework/common/gallery/upload',
                driver: 'local',
                domain: '',
                options: {
                    max: 1,
                    size: 20,
                    suffix: 'bmp,gif,jpg,jpeg,png',
                    type: 1,
                    cat: false,
                    tabs: false,
                    upload: true,
                    addPage: false,
                    addIcon: false,
                },
                fileTypeMaps: {
                    '1': 'image', '2': 'media', '3': 'file'
                },
                postHeaders: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                postData: {},
                operation: {
                    groupManage: false,
                    groupMax: 6,
                    imageTotal: 0,
                    dialog: false,
                    loading: false,
                    loadingMsg: '',
                    error: false
                },
                search: {
                    group_id: 0,
                    page: 1,
                    keyword: '',
                    size: 12,
                    type: 1
                },
                size:0,
                groupItems: [],
                imagesItems: [],
                selected: [],
            },
            CenterParams:{
                // 监测抽屉鼠标事件
                mousedownClassBol: false,//抽屉遮盖层误触
                dialogClassModel: '',//抽屉遮盖层误触
                // 监测抽屉鼠标事件 End.
                loadingMsg:'正在加载数据，请稍后...',
                dialog: false, loading: false,updatePasswordStatus:false,
                action: '',
                model: {name:'',account:'',password:''},
                rules: {
                    name: [
                        { required: true, message: '请填写用户名', trigger: 'blur'}
                    ],
                    account: [
                        { required: true, message: '请填写登录账号', trigger: 'blur'}
                    ]
                }
            },
        }
    },
    methods: {
        copy(context){
            let that = this
            navigator.clipboard.writeText(context)
                .then(()=>{
                    that.$Message('复制成功', 'success');
                })
                .catch(err => {
                    that.$Message('复制失败', 'warning');
                })
        },
        /*格式化时间戳*/
        formatTableDate: function (row, column, value) {
            if ((typeof (value) === 'undefined') || parseInt(value) === 0) {
                return '---';
            }
            return $Utils.formatDate('yyyy-MM-dd hh:mm:ss', value);
        },

        formatTableDay: function (row, column, value) {
            if ((typeof (value) === 'undefined') || parseInt(value) === 0) {
                return '---';
            }
            return $Utils.formatDate('yyyy-MM-dd', value);
        },

        // 金额千位分隔符（标准财务格式）
        formatMoney(amount) {
            return amount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
        },

        /*确认信息*/
        $Alerts: function (msg, successCallback, errorCallback, options) {
            options = options ? options : {
                type: 'warning',
                lockScroll: true,
                center: true,
                confirm: '确定',
                cancel: '取消',
                showClose: true,
                showCancelButton: true,
            };
            var that = this;
            that.$confirm(msg, '系统提示', {
                dangerouslyUseHTMLString: true,
                confirmButtonText: options.confirm ? options.confirm : '确定',
                cancelButtonText: options.cancel ? options.cancel : '取消',
                type: options.type ? options.type : 'warning',
                lockScroll: options.lockScroll ? options.lockScroll : false,
                showClose: options.showClose ? options.showClose : true,
                center: options.center ? options.center : true,
                showCancelButton: options.showCancelButton ? options.showCancelButton : true,
            }).then(function () {
                if (successCallback) {
                    successCallback();
                }
            }).catch(function () {
                if (errorCallback) {
                    errorCallback();
                }
            });
        },

        /*确认信息*/
        $Confirm: function (msg, successCallback, errorCallback, options) {
            var that = this;
            options = options ? options : {};
            var _s = Object.assign({
                dangerouslyUseHTMLString: true,
                lockScroll: false,
                type: 'warning',
                center: true,
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                closeOnClickModal: true,
                showCancelButton: true
            }, options);
            that.$confirm(msg, '系统提示', _s).then(function () {
                if (successCallback) {
                    successCallback();
                }
            }).catch(function () {
                if (errorCallback) {
                    errorCallback();
                }
            });
        },

        /*提示信息*/
        $Message: function (msg, callback, type, duration) {
            var that = this;
            if (typeof callback === 'string') {
                type = callback;
            } else {
                if (!type) {
                    type = 'success';  //warning  error
                }
            }
            duration = duration ? duration : 1500;
            that.$message({
                type: type, duration: duration, message: msg, dangerouslyUseHTMLString: true, onClose: function (res) {
                    if (callback && (typeof callback) === 'function') {
                        callback(res);
                    }
                }
            });
        },

        $Loading: function () {
            var loading = this.$loading({
                lock: true,
                text: 'Loading',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });
            setTimeout(() => {
                loading.close();
            }, 2000);
        },
        getLayoutsLeftMenus: function () {
            var that = this;
            that.getLayoutsTabsMenus();
            if (!that.layouts.left.show) return true;
            var currentItemId = parseInt(Cookies.get(that.layoutsLeftMenuEventKey));
            var currentItems = Cookies.get(that.currentItemsKey);
            var leftMenusItems = JSON.parse($Utils.decrypt(localStorage.getItem('leftMenusItems')));
            if (currentItemId) {
                that.layouts.left.active = currentItemId;
            } else {
                if ($Validator.json(currentItems)) {
                    currentItems = JSON.parse(currentItems);
                    that.layouts.left.active = currentItems.id;
                }
            }

            if (!leftMenusItems || $Public.request.debug) {
                $Request.postJson('framework/common/manage/leftMenuItems', {
                    headerParentId: that.layouts.left.headerParentId
                }, function (res) {
                    if (res.code === 200 && res.result) {
                        localStorage.setItem('leftMenusItems', $Utils.encrypt(JSON.stringify(res.result)));
                        that.layouts.left.show = true;
                        that.layouts.left.menus = res.result;
                        // console.log(that.layouts.left.menus);
                    } else {
                        that.layouts.left.show = false;
                    }
                });
            } else {
                that.layouts.left.show = true;
                that.layouts.left.menus = leftMenusItems;
            }
        },
        emptyChange: function () {
        },
        PermissionsCallbackEvent: function (res) {
            return true;
        },
        layoutsLeftMenuEvent: function (key, keyPath, e) {
            var that = this;
            var menuItems = e.$attrs.items;
            var $loading = that.$loading({
                lock: true,
                background: 'rgba(255, 255, 255, 0.4)'
            });
            if ((typeof e.$attrs.items) != 'object') {
                if (!$Validator.json(e.$attrs.items)) {
                    return true;
                }
                menuItems = JSON.parse(e.$attrs.items);
            }

            var currentItems = Cookies.getJSON(that.currentItemsKey);
            Cookies.set(that.layoutsLeftMenuEventKey, menuItems.id);
            Cookies.set(that.currentItemsKey, menuItems);
            that.layoutsTabsMenuEvent(menuItems);
            $Request.get(menuItems.path, {}, function (status) {
                $loading.close();
                if (status !== 200) {
                    Cookies.set(that.currentItemsKey, currentItems);
                    Cookies.set(that.layoutsLeftMenuEventKey, currentItems.id);
                    $Request.get(currentItems.path, {});
                }
            });
        },
        layoutsLeftMenuEventSet: function (menuItems) {
            var that = this
            var $loading = this.$loading({
                lock: true,
                background: 'rgba(255, 255, 255, 0.4)'
            });
            var currentItems = Cookies.getJSON(that.currentItemsKey);
            Cookies.set(that.layoutsLeftMenuEventKey, menuItems.id);
            Cookies.set(that.currentItemsKey, menuItems);
            $Request.get(menuItems.path, {}, function (status) {
                $loading.close();
                if (status !== 200) {
                    Cookies.set(that.currentItemsKey, currentItems);
                    Cookies.set(that.layoutsLeftMenuEventKey, currentItems.id);
                    $Request.get(currentItems.path, {});
                }
            });
        },
        layoutsTabsMenuClickEvent: function (e) {
            var that = this;
            if (!that.layouts.tabs.show) return false;
            if (!that.layouts.tabs.active || parseInt(that.layouts.tabs.active) === 0) {
                Cookies.remove(that.currentItemsKey);
                Cookies.remove(that.layoutsLeftMenuEventKey);
                $Request.get('/', {});
                return true;
            }
            $.each(that.layouts.tabs.menus, function (key, val) {
                if (parseInt(val.id) === parseInt(that.layouts.tabs.active)) {
                    that.layoutsLeftMenuEventSet(val);
                    return true;
                }
            });
        },
        layoutsTabsMenuRemoveEvent: function (e) {
            var that = this;
            var _Key = 0;
            if (!that.layouts.tabs.show) return false;
            $.each(that.layouts.tabs.menus, function (key, val) {
                if (parseInt(val.id) === e) {
                    _Key = (key + 1);
                    that.layouts.tabs.menus.splice(key, 1);
                    return false;
                }
            });
            var _Length = that.layouts.tabs.menus.length;
            if (_Length < 1) {
                sessionStorage.removeItem('9ca5hgd13b48hfcddfdab76c63ddf8u2');
                Cookies.remove(that.currentItemsKey);
                Cookies.remove(that.layoutsLeftMenuEventKey);
                $Request.get('/', {});
                return true;
            }
            sessionStorage.setItem('9ca5hgd13b48hfcddfdab76c63ddf8u2', JSON.stringify(that.layouts.tabs.menus));
            if (parseInt(that.layouts.tabs.active) === e) {
                if (parseInt(_Key) === 1) {
                    that.layoutsLeftMenuEventSet(that.layouts.tabs.menus[0]);
                    return true;
                }
                that.layoutsLeftMenuEventSet(that.layouts.tabs.menus[_Key - 2]);
            }
            return true;
        },
        layoutsTabsMenuEvent: function (items) {
            var that = this;
            var _isS = true;
            if (!that.layouts.tabs.show) return false;
            $.each(that.layouts.tabs.menus, function (key, val) {
                if (parseInt(val.id) === parseInt(items.id)) {
                    that.layouts.tabs.active = val.id;
                    _isS = false;
                    return true;
                }
            });
            if (_isS === true) {
                var menus = sessionStorage.getItem('9ca5hgd13b48hfcddfdab76c63ddf8u2');
                if (menus) {
                    menus = JSON.parse(menus);
                    menus.push(items);
                } else {
                    menus = [items];
                }
                sessionStorage.setItem('9ca5hgd13b48hfcddfdab76c63ddf8u2', JSON.stringify(menus));
                return true;
            }
        },
        layoutsTabsMenuCommandEvent: function (e) {
            var that = this;
            if (!that.layouts.tabs.show) return false;
            if (that.layouts.tabs.menus.length < 1) {
                return true;
            }
            if (e === 'all') {
                sessionStorage.removeItem('9ca5hgd13b48hfcddfdab76c63ddf8u2');
                Cookies.remove(that.currentItemsKey);
                Cookies.remove(that.layoutsLeftMenuEventKey);
                $Request.get('/', {});
                return true;
            } else if (e === 'other') {
                var tabsMenus = [];
                if (that.layouts.tabs.menus && that.layouts.tabs.menus.length > 0) {
                    if (parseInt(this.layouts.tabs.active) > 0) {
                        $.each(that.layouts.tabs.menus, function (key, val) {
                            if (parseInt(val.id) === parseInt(that.layouts.tabs.active)) {
                                tabsMenus[0] = val;
                            }
                        });
                        that.layouts.tabs.menus = tabsMenus;
                        sessionStorage.setItem('9ca5hgd13b48hfcddfdab76c63ddf8u2', JSON.stringify(tabsMenus));
                    } else {
                        sessionStorage.removeItem('9ca5hgd13b48hfcddfdab76c63ddf8u2');
                        Cookies.remove(that.currentItemsKey);
                        Cookies.remove(that.layoutsLeftMenuEventKey);
                        $Request.get('/', {});
                    }
                }
            } else {
                if (parseInt(this.layouts.tabs.active) > 0) {
                    that.layoutsTabsMenuRemoveEvent(that.layouts.tabs.active);
                }
            }
        },
        getLayoutsTabsMenus: function (items) {
            var that = this;
            if (!that.layouts.tabs.show) return false;
            that.layouts.tabs.menus = [];
            if (!that.layouts.tabs.show) return true;
            var currentItems = sessionStorage.getItem('9ca5hgd13b48hfcddfdab76c63ddf8u2');
            if (!currentItems) {
                return true;
            }
            currentItems = JSON.parse(currentItems);
            that.layouts.tabs.show = true;
            that.layouts.tabs.menus = currentItems;

        },
        /*获取页面操作项*/
        getUserOperationPermissions: function () {
            var that = this;
            if (!that.config.permissions) {
                return false;
            }

            that.permissions = [];
            var currentItemId = 0;
            if (that.config.menu_id) {
                currentItemId = that.config.menu_id;
            } else {
                currentItemId = Cookies.get(that.layoutsLeftMenuEventKey);
                if (!currentItemId) {
                    return true;
                }
            }
            $Request.postJson('framework/common/manage/operationPermissions', {menu_id: currentItemId}, function (res) {
                if (res.code === 200) {
                    that.permissions = res.result;
                    // console.log(that.permissions);
                    that.PermissionsCallbackEvent(res.result);
                }
            });
        },
        redirectPage: function (url, data, type) {
            var that = this;
            var backLoading = that.$loading({
                lock: true,
                background: 'rgba(255, 255, 255, 0.4)'
            });
            switch (type) {
                case 'load':
                    that.layouts.loading = true;
                    $Request.load(url, data);
                    break;
                case 'open':
                    backLoading.close();
                    $Request.open(url, data);
                    break;
                case 'reload':
                    window.location.reload();
                    break;
                case 'post':
                    $Request.postJson(url, data, function (res) {
                        backLoading.close();
                        that.$Message('成功！');
                    });
                    break;
                default:
                    that.layouts.loading = true;
                    $Request.get(url, data);
                    break;
            }

            return true;
        },
        /*计算页面高度*/
        computingWindowHeight: function (reload) {
            var that = this;
            if (reload === true) {
                if (that.layouts.isCollapse) {
                    that.layouts.isCollapse = false;
                    that.layouts.menuWidth = {'width': '220px !important'}
                } else {
                    that.layouts.isCollapse = true;
                    that.layouts.menuWidth = {'width': '64px !important'}
                }
                if (!that.layouts.left.show) {
                    that.layouts.isCollapse = false;
                    that.layouts.menuWidth = {'width': '0 !important'};
                }
            }


            var documentClientHeight = document.documentElement.clientHeight;
            that.layouts.containerHeight = {
                'height': (documentClientHeight - 20) + 'px',
            };

            that.layouts.mainHeight = {
                'min-height': (documentClientHeight - 120) + 'px',
            };

            that.layouts.drawerFormsHeight = {
                'max-height': parseInt((documentClientHeight * 0.71) - 120) + 'px'
            };

            that.layouts.dialogFormsHeight = {
                'max-height': parseInt((documentClientHeight * 0.81) - 120) + 'px'
            };

            that.layouts.drawerFixedHeight = {
                'height': (documentClientHeight - 131) + 'px',
            };

            that.layouts.dialogFixedHeight = {
                'height': (documentClientHeight - 380) + 'px',
            };

            that.layouts.windowHeight = documentClientHeight - 120;
        },
        handleCommand: function (command) {
            var that = this;
            switch (command) {
                case 'logout': //退出
                    that.logout();
                    break;
                case 'clear_cache':
                    that.clearCache();
                    break;
                case 'center':
                    that.centerDialogOpen();
                    break;
                default:
                    break;
            }
        },
        logout: function () {
            $Request.get('passport/logout', {});
        },
        clearCache: function () {
            this.redirectPage('framework/common/cacheClear', {}, 'post')
        },
        centerDialogOpen: function () {
            $Center.CenterDialogOpen();
        },
    },
    beforeCreate: function () {
    },

    created: function () {
        var that = this;
        that.layoutsLeftMenuEventKey = $('meta[name="layouts-left"]').attr('content');
        that.currentItemsKey = $('meta[name="current-items"]').attr('content');

        var is_login = $("#is_login").val();
        if (is_login) {
            var parents = Cookies.get(that.layoutsLeftMenuEventKey);
            if (parents) {
                var parents_arr = parents.split(',');
                if (parents_arr) {
                    that.layouts.left.openeds = parents_arr.map(function (data) {
                        return +data;
                    });
                }
            }
            that.getLayoutsLeftMenus();
            that.getUserOperationPermissions();
        }
        if ($('meta[name="framework-logout"]').attr('content') == 'logout') {
            that.$Confirm('当前账号已在其他设备登录，你已被下线！', function () {
                $Request.get('passport/logout');
            }, function () {
                $Request.get('passport/logout');
            }, {
                type: 'error',
                lockScroll: false,
                center: true,
                confirmButtonText: '重新登录',
                cancel: '退出登录',
                showClose: false,
                closeOnClickModal: false,
                closeOnPressEscape: false,
                showCancelButton: false
            });
        }
    },

    mounted: function () {
        var that = this;
        that.computingWindowHeight(true);
        $(window).resize(function () {
            that.computingWindowHeight(false);
        });
    }
};
var $Tables = {
    data: function () {
        return {
            tables: {
                remove: {url: '', msg: '', field: ''},
                status: {url: '', msg: '', field: '', maps: {1: '禁用', 2: '启用'}},
                sort: {url: '', item: '', field: ''},
                selects: [],
                options: {
                    cell: true,
                    loading: true,
                    loadingMsg: '正在加载数据，请稍后...'
                },
                url: '', search: {},
                prop: 'id',
                orderBy: 'desc',
                pagination: {
                    layouts: 'total, sizes, prev, pager, next, jumper',
                    sizes: [15, 30, 50, 100, 300, 500],
                    page: 1,
                    size: 15,
                    total: 20,
                },
                data: []
            },
        }
    },

    methods: {
        formatTableColumn: function (row, column, value) {

        },
        tablesCellMoveEvent: function (row, column, cell, event) {
            var that = this;
            if (column.filterPlacement === 'false' || !that.tables.options.cell) {
                return false;
            }
            event.stopPropagation();
            if ($(cell).find('.cell').hasClass('Va-table-move')) {
                return false;
            } else {
                $('.cell').removeClass('Va-table-move');
                $('.Va-table-move-close').remove();
                if (!row[column.property]) {
                    return false;
                }
                $(cell).find('.cell').append('<i class="el-icon-close Va-table-move-close" onclick="removeTableMoveEvent(this)"></i>');
                $(cell).find('.cell').addClass('Va-table-move');
                if (($(cell).width() - 20) > $(cell).parent().find('.Va-table-move').width()) {
                    $('.cell').removeClass('Va-table-move');
                    $('.Va-table-move-close').remove();
                }
            }
        },

        tablesPaginationSizeChange: function (size) {
            var that = this;
            that.tables.pagination.size = size;
            that.tablesGetTableList();
        },

        tablesPaginationCurrentChange: function (page) {
            var that = this;
            that.tables.pagination.page = page;
            that.$refs.formContainerTables.clearSelection();
            that.tablesGetTableList();
        },

        /*排序发生改变时触发*/
        tablesPaginationSortChange: function (rows) {
            var that = this;
            that.$set(that.tables, 'orderBy', rows.orderBy);
            if (typeof rows.column.sortBy === 'undefined') {
                that.$set(that.tables, 'prop', rows.prop);
            } else {
                that.$set(that.tables, 'prop', rows.column.sortBy);
            }
            that.tablesGetTableList();
        },

        /*多选发生改变时触发*/
        tablesSelectChange: function (rows) {
            var that = this;
            that.selects = rows;
            that.$set(that.tables, 'selects', rows);
        },

        tablesClearSelect: function () {
            var that = this;
            that.$nextTick(function () {
                that.$refs.formContainerTables.clearSelection();
            })
        },

        getTablesSelected: function () {
            var that = this;
            if (!that.tables.selects.length || that.tables.selects.length <= 0) {
                return [];
            }
            var selects_ids = [];
            that.tables.selects.forEach(function (item, index) {
                selects_ids.push(item.id);
            });
            if (!selects_ids || selects_ids.length <= 0) {
                return [];
            }
            return selects_ids;
        },

        tablesGetTableList: function () {
            var that = this;
            if (!that.tablesGetTableListFront()) {
                return false;
            }
            if (!that.tables.url) {
                that.tables.url = window.location.href;
            }
            that.tables.options.loading = true;
            that.tables.search.page = that.tables.pagination.page;
            that.tables.search.size = that.tables.pagination.size;
            that.tables.search.orderBy = that.tables.orderBy;
            that.tables.search.prop = that.tables.prop;
            $Request.postJson(that.tables.url, that.tables.search, function (res) {
                if (that.tablesGetTablesListsAfter(res)) {
                    if ((typeof (res) === 'undefined')) {
                        return false;
                    }
                    if ((typeof (res.result) === 'undefined')) {
                        return false;
                    }
                    // console.log(that.tables.data);
                    that.tables.options.loading = false;
                    that.tables.data = res.result.rows ? res.result.rows : res.result.data;
                    that.tables.pagination.total = res.result.total;
                }
                that.tablesGetTablesListsFinish(res);
            })
            if (that.parking && that.parking.search.store_id){
                that.getParkingList()
            }
        },

        tablesGetTableListFront: function () {
            return true;
        },
        tablesGetTablesListsAfter: function () {
            return true;
        },
        tablesGetTablesListsFinish: function () {
            return true;
        },

        tablesRowsRemove: function (rows, params) {
            var that = this;
            if (!that.tables.remove.url) {
                return false;
            }
            var requestData = {};

            if (params) {
                requestData = params;
            }

            that.tables.remove.msg = that.tables.remove.msg ? that.tables.remove.msg : '确认删除当前数据吗？';
            that.tables.remove.field = that.tables.remove.field ? that.tables.remove.field : 'id';
            if (!rows[that.tables.remove.field]) {
                return false;
            }
            requestData[that.tables.remove.field] = rows[that.tables.remove.field];

            that.$confirm(that.tables.remove.msg, '操作提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true,
                dangerouslyUseHTMLString: true,
                lockScroll: false,
            }).then(function () {
                $Request.postJson(that.tables.remove.url, requestData, function (res) {
                    if (res.code === 200) {
                        that.$message({
                            message: res.message, type: 'success', duration: 2400, onClose: function () {
                            }
                        });
                        that.tablesGetTableList();
                    } else {
                        that.$message({
                            message: res.message, type: 'error', duration: 2400, onClose: function () {
                            }
                        });
                    }
                })
            }).catch(function () {

            });
        },

        tablesRowsStatus: function (rows, params) {
            var that = this;


            if (!that.tables.status.url || !that.tables.status.field) {
                return false;
            }

            if (!rows[that.tables.status.field] && rows[that.tables.status.field] !== 0) {
                return false;
            }

            if (!that.tables.status.maps[rows[that.tables.status.field]]) {
                return false;
            }

            that.tables.status.msg = '确认' + that.tables.status.maps[rows[that.tables.status.field]] + '当前数据吗？';


            var requestData = {};

            if (params) {
                requestData = params;
            }

            requestData[that.tables.status.field] = rows[that.tables.status.field];

            that.$confirm(that.tables.status.msg, '操作提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: false,
                dangerouslyUseHTMLString: true,
                lockScroll: false,
            }).then(function () {
                $Request.postJson(that.tables.status.url, requestData, function (res) {
                    if (res.code === 200) {
                        that.$message({
                            message: res.message, type: 'success', duration: 2400, onClose: function () {
                            }
                        });
                        that.tablesGetTableList();
                    } else {
                        that.$message({
                            message: res.message, type: 'error', duration: 2400, onClose: function () {
                            }
                        });
                    }
                })
            }).catch(function () {

            });
        },

        tablesRowsSort: function (rows) {
            var that = this;
            if (!that.tables.sort.url) {
                return false;
            }
            var requestData = {};
            that.tables.sort.field = that.tables.sort.field ? that.tables.sort.field : 'id';
            that.tables.sort.item = that.tables.sort.item ? that.tables.sort.item : 'sort';
            if (!rows[that.tables.sort.field]) {
                return false;
            }
            if (!rows[that.tables.sort.item]) {
                return false;
            }
            requestData[that.tables.sort.field] = rows[that.tables.sort.field];
            requestData[that.tables.sort.item] = rows[that.tables.sort.item];
            $Request.postJson(that.tables.sort.url, requestData, function (res) {
                if (res.code === 200) {
                    that.$message({message: res.message, type: 'success', duration: 2100});
                    that.tablesGetTableList();
                } else {
                    that.$message({message: res.message, type: 'error', duration: 2100});
                }
            })
        },

        tablesRowsType: function (rows) {
            var that = this;
            if (!that.tables.type.url) {
                return false;
            }
            var requestData = {};
            that.tables.type.field = that.tables.type.field ? that.tables.type.field : 'id';
            that.tables.type.item = that.tables.type.item ? that.tables.type.item : 'type';
            if (!rows[that.tables.type.field]) {
                return false;
            }
            if (!rows[that.tables.type.item]) {
                return false;
            }
            requestData[that.tables.type.field] = rows[that.tables.type.field];
            requestData[that.tables.type.item] = rows[that.tables.type.item];
            $Request.postJson(that.tables.type.url, requestData, function (res) {
                if (res.code === 200) {
                    that.$message({message: res.message, type: 'success', duration: 2100});
                    that.tablesGetTableList();
                } else {
                    that.$message({message: res.message, type: 'error', duration: 2100});
                }
            })
        },

        tablesSearchEvent: function () {
            this.tables.pagination.page = 1;
            this.tablesGetTableList();
        },

        tablesResetsEvent: function () {

        },
    },

    mounted: function () {
        var that = this;
        that.tablesGetTableList();
    },

    beforeCreate: function () {
        var that = this;
    },

    created: function () {


    }
};
var $DrawerForms = {
    data: function () {
        return {
            drawerFormsOptions: {
                models: 'drawerForms',
                refs: 'create.model',
                status: false,
            },
            drawerOpens: [],
            __key: '',
            drawerForms: {},

            // 监测抽屉鼠标事件
            mousedownClassBol: false,//抽屉遮盖层误触
            drawerClassModel: '',//抽屉遮盖层误触
            // 监测抽屉鼠标事件 End.
        }
    },
    methods: {
        // 监测抽屉鼠标事件
        handleWrapperMousedown(e) {
            var that = this;
            // 如果为true，则表示点击发生在遮罩层
            that.drawerClassModel = !!e.target.classList.contains('el-drawer__container')
        },
        handleWrapperMouseup(e) {
            var that = this;
            if ((!!e.target.classList.contains('el-drawer__container')) && that.drawerClassModel) {
                that.drawerFormsCloses(that.drawerFormsOptions.models);
            }
        },
        // 监测抽屉鼠标事件 End.

        drawerFormsCloses: function (model) {
            var that = this;
            if (model && typeof model == 'string') that.drawerFormsOptions.models = model;

            that[that.drawerFormsOptions.models].drawer = false;
            that[that.drawerFormsOptions.models].loading = false;
            if (that.drawerOpens.length > 0) {
                that.drawerOpens.splice(that.drawerOpens.length - 1)
                that.drawerFormsOptions.models = that.drawerOpens[that.drawerOpens.length - 1] ? that.drawerOpens[that.drawerOpens.length - 1] : 'drawerForms'
            }
            if (that.$refs[that.drawerFormsOptions.refs]) {
                setTimeout(function () {
                    that.$refs[that.drawerFormsOptions.refs].resetFields();
                }, 500);
            }
        },

        drawerFormsBeforeCloses: function (model) {
            var that = this;
            if (model && typeof model == 'string') that.drawerFormsOptions.models = model;
            // console.log(that.drawerFormsOptions.models);
            that[that.drawerFormsOptions.models].drawer = false;
            that[that.drawerFormsOptions.models].loading = false;
        },

        drawerFormsSubmits: function (model) {
            var that = this;
            if (model && typeof model == 'string') that.drawerFormsOptions.models = model;
            /*防止重复提交*/
            if (that[that.drawerFormsOptions.models].loading) {
                return false;
            }
            if ((typeof (that.$refs[that.drawerFormsOptions.refs]) === 'undefined')) {
                that[that.drawerFormsOptions.models].loading = true;
                var formsdrawerFunction = that.drawerFormsOptions.models + 'FormsSubmits';
                if (that.hasOwnProperty(formsdrawerFunction)) {
                    that[formsdrawerFunction](that[that.drawerFormsOptions.models].model);
                } else {
                    that.drawerFormsRequests(that[that.drawerFormsOptions.models].model);
                }
                that[that.drawerFormsOptions.models].loading = false;
                return true;
            } else {
                that.$refs[that.drawerFormsOptions.refs].validate(function (valid) {
                    if (valid) {
                        that[that.drawerFormsOptions.models].loading = true;
                        var formsdrawerFunction = that.drawerFormsOptions.models + 'FormsSubmits';
                        if (that.hasOwnProperty(formsdrawerFunction)) {
                            that[formsdrawerFunction](that[that.drawerFormsOptions.models].model);
                        } else {
                            that.drawerFormsRequests(that[that.drawerFormsOptions.models].model);
                        }
                    } else {
                        that[that.drawerFormsOptions.models].loading = false;
                    }
                });
            }
        },

        drawerFormsOpens: function (model) {
            var that = this;
            that.config.__key = $Request.random(12);
            that.drawerFormsOptions.models = model;
            if ((typeof (model) === 'undefined') || (typeof (model) === 'object')) {
                that.drawerFormsOptions.models = 'drawerForms';
            }
            if ((typeof (that[that.drawerFormsOptions.models])) === 'undefined') {
                that[that.drawerFormsOptions.models] = {
                    drawer: false,
                    loading: false,
                    action: '',
                    model: {},
                    rules: {}
                };
            }
            if ((typeof (that[that.drawerFormsOptions.models].drawer)) === 'undefined') {
                that[that.drawerFormsOptions.models].drawer = false;
            }

            if ((typeof (that[that.drawerFormsOptions.models].loading)) === 'undefined') {
                that[that.drawerFormsOptions.models].loading = false;
            }
            if ((typeof (that[that.drawerFormsOptions.models].loadingTables)) === 'undefined') {
                that[that.drawerFormsOptions.models].loadingTables = true;
            }
            if ((typeof (that[that.drawerFormsOptions.models].model)) === 'undefined') {
                that[that.drawerFormsOptions.models].model = {};
            }

            if ((typeof (that[that.drawerFormsOptions.models].rules)) === 'undefined') {
                that[that.drawerFormsOptions.models].rules = {};
            }

            that.drawerFormsOptions.refs = that.drawerFormsOptions.models + '.model';
            that.drawerFormsOptions.status = true;
            that.drawerOpens.push(that.drawerFormsOptions.models);
            that[that.drawerFormsOptions.models].drawer = true;
            that[that.drawerFormsOptions.models].loading = false;
            if (!(typeof (that.$refs[that.drawerFormsOptions.refs]) === 'undefined')) {
                that.$refs[that.drawerFormsOptions.refs].resetFields();
            }
            return true;
        },

        drawerFormsRequests: function (model) {
            var that = this;
            if (!that[that.drawerFormsOptions.models].action) {
                console.error('$drawerForms：Forms component does not configure submit parameters！');
                that[that.drawerFormsOptions.models].loading = false;
                return false;
            }
            $Request.postJson(that[that.drawerFormsOptions.models].action, model, function (res) {
                if (res.code === 200) {
                    that.$message({
                        message: res.message, type: 'success', duration: 1500, onClose: function () {
                            if (that.hasOwnProperty('tablesGetTableList')) {
                                that[that.drawerFormsOptions.models].loading = false;
                                that[that.drawerFormsOptions.models].drawer = false;
                                if (that[that.drawerFormsOptions.models].loadingTables) {
                                    that.tablesGetTableList();
                                }

                                that.drawerFormsRequestsAfter(res);
                            }
                            if (that[that.drawerFormsOptions.models].success) {
                                var success = that[that.drawerFormsOptions.models].success;
                                if (that.hasOwnProperty(success)) {
                                    that[success](res)
                                }
                            }
                        }
                    });

                } else {
                    that[that.drawerFormsOptions.models].loading = false;
                    that.$message({message: res.message, type: 'error', duration: 1500});
                }
            });
        },

        drawerFormsRequestsAfter: function () {
            return true;
        },

        drawerFormsRequestsErrors: function () {
            var that = this;
        },

        drawerFormsValidateErrors: function (forms) {
            var that = this;
        },

        drawerListPageFormsOpens:function (model) {
            var that = this;
            var __table = that[model].model.__table;
            $Request.postJson('arts/setup/pageGetSetup', {__table: __table}, function (res) {
                if(res.code === 200){
                    if(res.result && !Array.isArray(res.result)) {
                        that[model].model = res.result;
                    }
                    that[model].model.__table = __table;
                }
                that.drawerFormsOpens(model);
            })
        }
    },

    mounted: function () {

    },
    beforeCreate: function () {
        var that = this;
    },

    created: function () {
        var that = this;
    }
};
var $DialogForms = {
    data: function () {
        return {
            dialogFormsOptions: {
                models: 'dialogForms',
                refs: 'create.model',
                status: false,
            },
            dialogOpens: [],
            __key: '',
            dialogForms: {},
            // 监测抽屉鼠标事件
            mousedownClassBol: false,//抽屉遮盖层误触
            dialogClassModel: '',//抽屉遮盖层误触
            // 监测抽屉鼠标事件 End.
        }
    },
    methods: {
        // 监测抽屉鼠标事件
        handleWrapperMousedown(e) {
            var that = this;
            // 如果为true，则表示点击发生在遮罩层
            that.dialogClassModel = !!e.target.classList.contains('el-dialog__wrapper')
        },
        handleWrapperMouseup(e) {
            var that = this;
            if ((!!e.target.classList.contains('el-dialog__wrapper')) && that.dialogClassModel) {
                that.dialogFormsCloses(that.dialogFormsOptions.models);
            }
        },
        // 监测抽屉鼠标事件 End.

        dialogFormsCloses: function (model) {
            var that = this;

            if (model && typeof model == 'string') that.dialogFormsOptions.models = model;

            that[that.dialogFormsOptions.models].dialog = false;
            that[that.dialogFormsOptions.models].loading = false;
            if (that.dialogOpens.length > 0) {
                that.dialogOpens.splice(that.dialogOpens.length - 1)
                that.dialogFormsOptions.models = that.dialogOpens[that.dialogOpens.length - 1] ? that.dialogOpens[that.dialogOpens.length - 1] : 'drawerForms'
            }
            if (that.$refs[that.dialogFormsOptions.refs]) {
                setTimeout(function () {
                    that.$refs[that.dialogFormsOptions.refs].resetFields();
                }, 500);
            }
        },

        dialogFormsBeforeCloses: function (model) {
            var that = this;
            if (model && typeof model == 'string') that.dialogFormsOptions.models = model;
            // console.log(that.dialogFormsOptions.models);
            that[that.dialogFormsOptions.models].dialog = false;
            that[that.dialogFormsOptions.models].loading = false;
        },

        dialogFormsSubmits: function (model) {
            var that = this;
            if (model && typeof model == 'string') that.dialogFormsOptions.models = model;
            /*防止重复提交*/
            if (that[that.dialogFormsOptions.models].loading) {
                return false;
            }
            if ((typeof (that.$refs[that.dialogFormsOptions.refs]) === 'undefined')) {
                that[that.dialogFormsOptions.models].loading = true;
                var formsdialogFunction = that.dialogFormsOptions.models + 'FormsSubmits';
                if (that.hasOwnProperty(formsdialogFunction)) {
                    that[formsdialogFunction](that[that.dialogFormsOptions.models].model);
                } else {
                    that.dialogFormsRequests(that[that.dialogFormsOptions.models].model);
                }
                that[that.dialogFormsOptions.models].loading = false;
                return true;
            } else {
                that.$refs[that.dialogFormsOptions.refs].validate(function (valid) {
                    if (valid) {
                        that[that.dialogFormsOptions.models].loading = true;
                        var formsdialogFunction = that.dialogFormsOptions.models + 'FormsSubmits';
                        if (that.hasOwnProperty(formsdialogFunction)) {
                            that[formsdialogFunction](that[that.dialogFormsOptions.models].model);
                        } else {
                            that.dialogFormsRequests(that[that.dialogFormsOptions.models].model);
                        }
                    } else {
                        that[that.dialogFormsOptions.models].loading = false;
                    }
                });
            }
        },

        dialogFormsOpens: function (model) {
            var that = this;
            that.config.__key = $Request.random(12);
            that.dialogFormsOptions.models = model;
            if ((typeof (model) === 'undefined') || (typeof (model) === 'object')) {
                that.dialogFormsOptions.models = 'dialogForms';
            }
            if ((typeof (that[that.dialogFormsOptions.models])) === 'undefined') {
                that[that.dialogFormsOptions.models] = {
                    dialog: false,
                    loading: false,
                    action: '',
                    model: {},
                    rules: {}
                };
            }
            if ((typeof (that[that.dialogFormsOptions.models].dialog)) === 'undefined') {
                that[that.dialogFormsOptions.models].dialog = false;
            }

            if ((typeof (that[that.dialogFormsOptions.models].loading)) === 'undefined') {
                that[that.dialogFormsOptions.models].loading = false;
            }
            if ((typeof (that[that.dialogFormsOptions.models].loadingTables)) === 'undefined') {
                that[that.dialogFormsOptions.models].loadingTables = true;
            }
            if ((typeof (that[that.dialogFormsOptions.models].model)) === 'undefined') {
                that[that.dialogFormsOptions.models].model = {};
            }

            if ((typeof (that[that.dialogFormsOptions.models].rules)) === 'undefined') {
                that[that.dialogFormsOptions.models].rules = {};
            }

            that.dialogFormsOptions.refs = that.dialogFormsOptions.models + '.model';
            that.dialogFormsOptions.status = true;
            that[that.dialogFormsOptions.models].dialog = true;
            that[that.dialogFormsOptions.models].loading = false;
            if (!(typeof (that.$refs[that.dialogFormsOptions.refs]) === 'undefined')) {
                that.$refs[that.dialogFormsOptions.refs].resetFields();
            }
            return true;
        },

        dialogFormsRequests: function (model) {
            var that = this;
            if (!that[that.dialogFormsOptions.models].action) {
                console.error('$dialogForms：Forms component does not configure submit parameters！');
                that[that.dialogFormsOptions.models].loading = false;
                return false;
            }
            $Request.postJson(that[that.dialogFormsOptions.models].action, model, function (res) {
                if (res.code === 200) {
                    that.$message({
                        message: res.message, type: 'success', duration: 1500, onClose: function () {
                            if (that.hasOwnProperty('tablesGetTableList')) {
                                that[that.dialogFormsOptions.models].loading = false;
                                that[that.dialogFormsOptions.models].dialog = false;
                                if (that[that.dialogFormsOptions.models].loadingTables) {
                                    that.tablesGetTableList();
                                    that.tablesDialogGetTableList();
                                }

                                that.dialogFormsRequestsAfter(res);
                            }
                            if (that[that.dialogFormsOptions.models].success) {
                                that[that.dialogFormsOptions.models].loading = false;
                                var success = that[that.dialogFormsOptions.models].success;
                                if (that.hasOwnProperty(success)) {
                                    that[success](res)
                                }
                            }
                        }
                    });

                } else {
                    that[that.dialogFormsOptions.models].loading = false;
                    that.$message({message: res.message, type: 'error', duration: 1500});
                }
            });
        },

        dialogFormsRequestsAfter: function () {
            return true;
        },

        dialogFormsRequestsErrors: function () {
            var that = this;
        },

        dialogFormsValidateErrors: function (forms) {
            var that = this;
        },

        dialogListPageFormsOpens:function (model) {
            var that = this;
            var __table = that[model].model.__table;
            $Request.postJson('arts/setup/pageGetSetup', {__table: __table}, function (res) {
                if(res.code === 200){
                    if(res.result && !Array.isArray(res.result)) {
                        that[model].model = res.result;
                    }
                    that[model].model.__table = __table;
                }
                that.dialogFormsOpens(model);
            })
        }
    },

    mounted: function () {

    },
    beforeCreate: function () {
        var that = this;
    },

    created: function () {
        var that = this;
    }
};
var $Login = {
    data: function () {
        return {}
    },
    methods: {
        hasClass: function (elem, cls) {
            cls = cls || '';
            if (cls.replace(/\s/g, '').length == 0) return false; //当cls没有参数时，返回false
            return new RegExp(' ' + cls + ' ').test(' ' + elem.className + ' ');
        },
        addClass(ele, cls) {
            if (!this.hasClass(ele, cls)) {
                ele.className = ele.className == '' ? cls : ele.className + ' ' + cls;
            }
        },
        removeClass(ele, cls) {
            if (this.hasClass(ele, cls)) {
                var newClass = ' ' + ele.className.replace(/[\t\r\n]/g, '') + ' ';
                while (newClass.indexOf(' ' + cls + ' ') >= 0) {
                    newClass = newClass.replace(' ' + cls + ' ', ' ');
                }
                ele.className = newClass.replace(/^\s+|\s+$/g, '');
            }
        },
        removeLocal(){
            Cookies.remove('9ca8e8d13b4369cddfdab26c63d69ce2');
            Cookies.remove('f63dcfe3c89a14e80c9cdf60b4b94f4b');
            localStorage.clear();
            sessionStorage.clear();
        }
    },
    beforeCreate: function () {
    },

    created: function () {
    },

    mounted: function () {
        //设置主体
        var $theme = Cookies.get('theme');
        this.themeCommandEvent($theme ? $theme : 'index');
    }
};
var $TableDialog = {
    data: function () {
        return {
            tableDialog:{
                model: 'dialog'
            }
        }
    },

    methods: {
        formatTableDialogColumn: function (row, column, value) {},
        tablesDialogCellMoveEvent: function (row, column, cell, event) {
            var that = this;
            if (column.filterPlacement === 'false' || !that[that.tableDialog.models].options.cell) {
                return false;
            }
            event.stopPropagation();
            if ($(cell).find('.cell').hasClass('Va-table-move')) {
                return false;
            } else {
                $('.cell').removeClass('Va-table-move');
                $('.Va-table-move-close').remove();
                if (!row[column.property]) {
                    return false;
                }
                $(cell).find('.cell').append('<i class="el-icon-close Va-table-move-close" onclick="removeTableMoveEvent(this)"></i>');
                $(cell).find('.cell').addClass('Va-table-move');
                if (($(cell).width() - 20) > $(cell).parent().find('.Va-table-move').width()) {
                    $('.cell').removeClass('Va-table-move');
                    $('.Va-table-move-close').remove();
                }
            }
        },

        tablesDialogPaginationSizeChange: function (size) {
            var that = this;
            that[that.tableDialog.models].pagination.size = size;
            that.tablesDialogGetTableList();
        },

        tablesDialogPaginationCurrentChange: function (page) {
            var that = this;
            that[that.tableDialog.models].pagination.page = page;
            that.$refs.formContainerTables.clearSelection();
            that.tablesDialogGetTableList();
        },

        /*排序发生改变时触发*/
        tablesDialogPaginationSortChange: function (rows) {
            var that = this;
            that.$set(that[that.tableDialog.models], 'orderBy', rows.orderBy);
            if (typeof rows.column.sortBy === 'undefined') {
                that.$set(that[that.tableDialog.models], 'prop', rows.prop);
            } else {
                that.$set(that[that.tableDialog.models], 'prop', rows.column.sortBy);
            }
            that.tablesDialogGetTableList();
        },

        /*多选发生改变时触发*/
        tablesDialogSelectChange: function (rows) {
            var that = this;
            that.selects = rows;
            that.$set(that[that.tableDialog.models], 'selects', rows);
        },

        tablesDialogClearSelect: function () {
            var that = this;
            that.$nextTick(function () {
                that.$refs.formContainerTables.clearSelection();
            })
        },

        getTablesDialogSelected: function () {
            var that = this;
            if (!that[that.tableDialog.models].selects.length || that[that.tableDialog.models].selects.length <= 0) {
                return [];
            }
            var selects_ids = [];
            that[that.tableDialog.models].selects.forEach(function (item, index) {
                selects_ids.push(item.id);
            });
            if (!selects_ids || selects_ids.length <= 0) {
                return [];
            }
            return selects_ids;
        },

        tablesDialogGetTableList: function (model) {
            var that = this;
            if (model && typeof model == 'string') that.tableDialog.models = model;
            if (!that.tablesDialogGetTableListFront()) {
                return false;
            }
            if (!that[that.tableDialog.models].url) {
                that[that.tableDialog.models].url = window.location.href;
            }
            that[that.tableDialog.models].options.loading = true;
            that[that.tableDialog.models].search.page = that[that.tableDialog.models].pagination.page;
            that[that.tableDialog.models].search.size = that[that.tableDialog.models].pagination.size;
            that[that.tableDialog.models].search.orderBy = that[that.tableDialog.models].orderBy;
            that[that.tableDialog.models].search.prop = that[that.tableDialog.models].prop;
            $Request.postJson(that[that.tableDialog.models].url, that[that.tableDialog.models].search, function (res) {
                if (that.tablesDialogGetTablesListsAfter(res)) {
                    if ((typeof (res) === 'undefined')) {
                        return false;
                    }
                    if ((typeof (res.result) === 'undefined')) {
                        return false;
                    }
                    that[that.tableDialog.models].options.loading = false;
                    that[that.tableDialog.models].data = res.result.rows ? res.result.rows : res.result.data;
                    that[that.tableDialog.models].pagination.total = res.result.total;
                }
                that.tablesDialogGetTablesListsFinish(res);
            })
        },

        tablesDialogGetTableListFront: function () {
            return true;
        },
        tablesDialogGetTablesListsAfter: function () {
            return true;
        },
        tablesDialogGetTablesListsFinish: function () {
            return true;
        },

        tablesDialogRowsRemove: function (model, rows, params) {
            var that = this;

            if (model && typeof model == 'string') that.tableDialog.models = model;

            if (!that[that.tableDialog.models].remove.url) {
                return false;
            }
            var requestData = {};

            if (params) {
                requestData = params;
            }

            that[that.tableDialog.models].remove.msg = that[that.tableDialog.models].remove.msg ? that[that.tableDialog.models].remove.msg : '确认删除当前数据吗？';
            that[that.tableDialog.models].remove.field = that[that.tableDialog.models].remove.field ? that[that.tableDialog.models].remove.field : 'id';
            if (!rows[that.tables.remove.field]) {
                return false;
            }
            requestData[that[that.tableDialog.models].remove.field] = rows[that[that.tableDialog.models].remove.field];

            that.$confirm(that[that.tableDialog.models].remove.msg, '操作提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true,
                dangerouslyUseHTMLString: true,
                lockScroll: false,
            }).then(function () {
                $Request.postJson(that[that.tableDialog.models].remove.url, requestData, function (res) {
                    if (res.code === 200) {
                        that.$message({
                            message: res.message, type: 'success', duration: 2400, onClose: function () {
                            }
                        });
                        that.tablesDialogGetTableList();
                    } else {
                        that.$message({
                            message: res.message, type: 'error', duration: 2400, onClose: function () {
                            }
                        });
                    }
                })
            }).catch(function () {

            });
        },

        tablesDialogRowsStatus: function (model, rows, params) {
            var that = this;

            if (model && typeof model == 'string') that.tableDialog.models = model;

            if (!that[that.tableDialog.models].status.url || !that[that.tableDialog.models].status.field) {
                return false;
            }

            if (!rows[that[that.tableDialog.models].status.field] && rows[that[that.tableDialog.models].status.field] !== 0) {
                return false;
            }

            if (!that[that.tableDialog.models].status.maps[rows[that[that.tableDialog.models].status.field]]) {
                return false;
            }

            that[that.tableDialog.models].status.msg = '确认' + that[that.tableDialog.models].status.maps[rows[that[that.tableDialog.models].status.field]] + '当前数据吗？';


            var requestData = {};

            if (params) {
                requestData = params;
            }

            requestData[that[that.tableDialog.models].status.field] = rows[that[that.tableDialog.models].status.field];

            that.$confirm(that[that.tableDialog.models].status.msg, '操作提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: false,
                dangerouslyUseHTMLString: true,
                lockScroll: false,
            }).then(function () {
                $Request.postJson(that[that.tableDialog.models].status.url, requestData, function (res) {
                    if (res.code === 200) {
                        that.$message({
                            message: res.message, type: 'success', duration: 2400, onClose: function () {
                            }
                        });
                        that.tablesDialogGetTableList();
                    } else {
                        that.$message({
                            message: res.message, type: 'error', duration: 2400, onClose: function () {
                            }
                        });
                    }
                })
            }).catch(function () {

            });
        },

        tablesDialogRowsSort: function (model, rows) {
            var that = this;

            if (model && typeof model == 'string') that.tableDialog.models = model;

            if (!that[that.tableDialog.models].sort.url) {
                return false;
            }
            var requestData = {};
            that[that.tableDialog.models].sort.field = that[that.tableDialog.models].sort.field ? that[that.tableDialog.models].sort.field : 'id';
            that[that.tableDialog.models].sort.item = that[that.tableDialog.models].sort.item ? that[that.tableDialog.models].sort.item : 'sort';
            if (!rows[that[that.tableDialog.models].sort.field]) {
                return false;
            }
            if (!rows[that[that.tableDialog.models].sort.item]) {
                return false;
            }
            requestData[that[that.tableDialog.models].sort.field] = rows[that[that.tableDialog.models].sort.field];
            requestData[that[that.tableDialog.models].sort.item] = rows[that[that.tableDialog.models].sort.item];
            $Request.postJson(that[that.tableDialog.models].sort.url, requestData, function (res) {
                if (res.code === 200) {
                    that.$message({message: res.message, type: 'success', duration: 2100});
                    that.tablesDialogGetTableList();
                } else {
                    that.$message({message: res.message, type: 'error', duration: 2100});
                }
            })
        },

        tablesDialogRowsType: function (rows) {
            var that = this;

            if (model && typeof model == 'string') that.tableDialog.models = model;

            if (!that[that.tableDialog.models].type.url) {
                return false;
            }
            var requestData = {};
            that[that.tableDialog.models].type.field = that[that.tableDialog.models].type.field ? that[that.tableDialog.models].type.field : 'id';
            that[that.tableDialog.models].type.item = that[that.tableDialog.models].type.item ? that[that.tableDialog.models].type.item : 'type';
            if (!rows[that[that.tableDialog.models].type.field]) {
                return false;
            }
            if (!rows[that[that.tableDialog.models].type.item]) {
                return false;
            }
            requestData[that[that.tableDialog.models].type.field] = rows[that[that.tableDialog.models].type.field];
            requestData[that[that.tableDialog.models].type.item] = rows[that[that.tableDialog.models].type.item];
            $Request.postJson(that[that.tableDialog.models].type.url, requestData, function (res) {
                if (res.code === 200) {
                    that.$message({message: res.message, type: 'success', duration: 2100});
                    that.tablesDialogGetTableList();
                } else {
                    that.$message({message: res.message, type: 'error', duration: 2100});
                }
            })
        },

        tablesDialogSearchEvent: function (model) {
            var that = this;
            if (model && typeof model == 'string') that.tableDialog.models = model;
            that[that.tableDialog.models].pagination.page = 1;
            that.tablesDialogGetTableList();
        },

        tablesDialogResetsEvent: function () {},
    },

    mounted: function () {},

    beforeCreate: function () {},

    created: function () {}
};
window.$Utils = {
    formatDate: function (fmt, time) {
        time = time ? time * 1000 : (new Date()).getTime();
        var date = new Date(parseInt(time));
        var o = {
            "M+": date.getMonth() + 1,
            "d+": date.getDate(),
            "h+": date.getHours(),
            "m+": date.getMinutes(),
            "s+": date.getSeconds(),
            "q+": Math.floor((date.getMonth() + 3) / 3),
            "S": date.getMilliseconds()
        };
        if (/(y+)/.test(fmt))
            fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt))
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    },
    // 处理admin前缀连接
    getAdminPrefix(url){
        var prefix = $('meta[name="prefix"]').attr('content');
        if (!url){
            return url;
        }
        if (url.startsWith('/') && url !== '/') {
            return url;
        }
        if (url === '/'){
            return "/" + prefix;
        }
        return "/" + prefix + "/" + url;
    },

    /*加密数据*/
    encrypt: function (str, KEY, IV) {
        if (!str) return false;
        KEY = KEY ? KEY : $Public.request.key;
        IV = IV ? IV : $Public.request.iv;
        var key = CryptoJS.enc.Utf8.parse(KEY);
        var iv = CryptoJS.enc.Utf8.parse(IV);
        var encrypted = CryptoJS.AES.encrypt(str, key, {
            iv: iv,
            mode: CryptoJS.mode.CBC,
            padding: CryptoJS.pad.Pkcs7
        });
        return encrypted.toString();
    },

    /*解密数据*/
    decrypt: function (str, KEY, IV) {
        if (!str) return false;
        KEY = KEY ? KEY : $Public.request.key;
        IV = IV ? IV : $Public.request.iv;

        var key = CryptoJS.enc.Utf8.parse(KEY);
        var iv = CryptoJS.enc.Utf8.parse(IV);
        var decrypted = CryptoJS.AES.decrypt(str, key, {
            iv: iv,
            padding: CryptoJS.pad.Pkcs7
        });
        return decrypted.toString(CryptoJS.enc.Utf8);
    },
};
window.$Public = {
    request: {
        key: '5B9ADC14C705F1B041DDC2D9B16A2D94',
        iv: '33092152342590AD',
        encrypt: true,
        debug: true,
    }
};
window.$Validator = {
    json: function (str) {
        if (typeof str == 'string') {
            try {
                var obj = JSON.parse(str);
                if (typeof obj == 'object' && obj) {
                    return true;
                } else {
                    return false;
                }
            } catch (e) {
                return false;
            }
        } else {
            return false;
        }
    },

    typeOf: function (str, type) {
        if ((typeof str) === type) {
            return true;
        } else {
            return false;
        }

    }
};
window.$Gallery = {
    GalleryDialogOpen: function (options) {
        $App.GalleryParams.options = Object.assign({
            max: 10,//上传条数
            size: 20, //上传大小
            type: '1',//文件类型；1：图片；2：视频；3：音频；4：文件；5：图标；20：网页
            tabs: false,//是否使用多标签菜单
            suffix: '', //上传类型
            multiple: true, //多选
            file_name: '',
            callback: function (result) {
            },
        }, options);
        $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
        $Gallery.GalleryUploadInit();
        $App.GalleryParams.operation.dialog = true;
    },

    GalleryDialogPages: function (options) {
        $App.GalleryParams.selected = [];
        $App.GalleryParams.search.keyword = '';
        $App.GalleryParams.options = Object.assign({
            max: 1,//上传条数
            size: 20, //上传大小
            type: '1',//文件类型；1：图片；2：视频；3：音频；4：文件；5：图标；20：网页
            tabs: false,//是否使用多标签菜单
            suffix: '', //上传类型
            multiple: false, //多谢
            callback: function (result) {
            },
        }, options);
        $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
        $Gallery.GalleryUploadInit();
    },

    GalleryUploadToken: function (callback, type) {
        type = type ? type : $App.GalleryParams.options.type;
        $Request.postJson('framework/common/uploadToken', {type: type}, function (res) {
            if (res.code === 200) {
                if ($Validator.typeOf(callback, 'function')) {
                    callback(res.result);
                    return true;
                }
                if (res.result.driver === "qiniu") {
                    $App.GalleryParams.driver = res.result.driver;
                    $App.GalleryParams.action = res.result.action;
                    $App.GalleryParams.domain = res.result.domain;
                    $App.GalleryParams.postData.token = res.result.token;
                    if (res.result.key) {
                        $App.GalleryParams.postData.key = res.result.key;
                    }
                    if (res.result.save_path) {
                        // TODO
                    }
                }

                if (res.result.driver === "oss") {
                    $App.GalleryParams.driver = res.result.driver;
                    $App.GalleryParams.action = res.result.ssl + '://' + res.result.domain;
                    $App.GalleryParams.domain = res.result.ssl + '://' + res.result.domain;
                    $App.GalleryParams.postData.OSSAccessKeyId = res.result.accessKeyId;
                    $App.GalleryParams.postData.policy = res.result.policy;
                    $App.GalleryParams.postData.Signature = res.result.signature;
                    // $App.GalleryParams.postData['x-oss-security-token'] = res.result.stsToken;
                    $App.GalleryParams.postData.bucket = res.result.bucket;
                    $App.GalleryParams.postData.region = res.result.region;
                    $App.GalleryParams.postData.success_action_status = 200;
                    if (res.result.save_path) {
                        // TODO
                    }
                }

                if (res.result.driver === "cos"){
                    // console.log(res.result)
                    $App.GalleryParams.driver = res.result.driver;
                    $App.GalleryParams.action = res.result.ssl + '://' + res.result.domain;
                    $App.GalleryParams.domain = res.result.ssl + '://' + res.result.domain;
                    $App.GalleryParams.postData.policy = res.result.policy;
                    $App.GalleryParams.postData.success_action_status = 200;
                    $App.GalleryParams.postData['q-sign-algorithm'] = res.result.q_sign_algorithm;
                    $App.GalleryParams.postData['q-ak'] = res.result.q_ak;
                    $App.GalleryParams.postData['q-key-time'] = res.result.q_key_time;
                    $App.GalleryParams.postData['q-signature'] = res.result.q_signature;
                    if (res.result.key) {
                        $App.GalleryParams.postData.key = res.result.key;
                    }
                    if (res.result.save_path) {
                        // TODO
                    }
                }

                if (res.result.driver === 'local') {
                    $App.GalleryParams.action = res.result.action;
                }
            } else {
                callback(false);
            }
        })
    },

    GalleryUploadInit: function () {
        var that = this;
        $App.GalleryParams.selected = [];
        $App.GalleryParams.search.keyword = '';
        $App.GalleryParams.search.page = 1;
        $App.GalleryParams.search.size = 12;
        $App.GalleryParams.options.upload = true;
        $App.GalleryParams.options.suffix = '';
        $App.GalleryParams.options.addPage = '';
        $App.GalleryParams.options.addIcon = '';
        switch (parseInt($App.GalleryParams.options.type)) {
            case 1://图片
                $App.GalleryParams.options.suffix = $App.GalleryParams.options.suffix ?
                    $App.GalleryParams.options.suffix : 'bmp,gif,jpg,jpeg,png';
                break;
            case 2://视频
                $App.GalleryParams.options.suffix = $App.GalleryParams.options.suffix ?
                    $App.GalleryParams.options.suffix : 'mp3,wma,avi,rm,rmvb,flv,mpg,mov,mk,mp4';
                break;
            case 3://文件
                $App.GalleryParams.options.suffix = $App.GalleryParams.options.suffix ?
                    $App.GalleryParams.options.suffix : 'doc,docx,xls,xlsx,xlsm,xlt,csv';
                break;
            case 4://网页
                $App.GalleryParams.options.suffix = '';
                $App.GalleryParams.options.upload = false;
                $App.GalleryParams.options.addPage = true;
                $App.GalleryParams.options.addIcon = false;
                $App.GalleryParams.search.size = 7;
                break;
            case 5://音频
                break;
            case 20:
                $App.GalleryParams.options.suffix = '';
                $App.GalleryParams.options.upload = false;
                $App.GalleryParams.options.addIcon = true;
                $App.GalleryParams.options.addPage = false;
                break;
            default:
        }
        $App.GalleryParams.search.type = $App.GalleryParams.options.type;
        $App.GalleryParams.imagesItems = [];
        $App.GalleryParams.operation.imageTotal = 0;
        $App.GalleryParams.search.group_id = 0;
        $Gallery.GalleryUploadParams();
        $Gallery.GalleryRequestLists();
    },

    GalleryUploadParams: function () {
        $App.GalleryParams.postData = {
            type: $App.GalleryParams.options.type,
            size: $App.GalleryParams.options.size,
            suffix: $App.GalleryParams.options.suffix,
            max: $App.GalleryParams.options.max,
            group_id: $App.GalleryParams.search.group_id,
            dir: '',
            file_name: $App.GalleryParams.options.file_name
        };
    },

    GalleryUploadProgress: function (event, file, fileList) {
        if ($App.GalleryParams.operation.error === false) {
            $App.GalleryParams.operation.loading = true;
            $App.GalleryParams.operation.loadingMsg = '文件正在上传 (' + parseFloat((event.percent).toFixed(2)) + '%), 请稍后...';
        }
    },

    GalleryUploadSuccess: function (response, file, fileList) {
        let params = {};
        // console.log('size:',$App.GalleryParams.size)
        switch ($App.GalleryParams.driver) {
            case 'qiniu':
                response.group_id = $App.GalleryParams.search.group_id;
                response.type = $App.GalleryParams.search.type;
                response.code = 200;
                response.url = $App.GalleryParams.domain + '/' + response.key;
                response.file_name = $App.GalleryParams.options.file_name;
                response.size = $App.GalleryParams.size;
                if (response.code === 200) {
                    $Request.postJson('framework/common/gallery/insert', response, function (res) {
                        if (res.code !== 200) {
                            $App.$Message(res.message, 'warning');
                            return true;
                        }
                        $App.$Message('文件上传成功！');
                        $App.GalleryParams.operation.loadingMsg = '';
                        $App.GalleryParams.operation.loading = false;
                        $App.$refs.GalleryDialogUpload.clearFiles();
                        $App.GalleryParams.search.page = 1;
                        $Gallery.GalleryRequestLists();
                        $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
                    });
                }
                break;
            case'oss':
            case'cos':
                params.group_id = $App.GalleryParams.search.group_id;
                params.type = $App.GalleryParams.search.type;
                params.code = 200;
                params.url = $App.GalleryParams.domain + '/' + $App.GalleryParams.postData.key;
                params.file_name = $App.GalleryParams.options.file_name;
                params.size = $App.GalleryParams.size;
                params.driver = $App.GalleryParams.driver;
                params.key = $App.GalleryParams.postData.key;
                if (params.code === 200){
                    $Request.postJson('framework/common/gallery/insert', params, function (res) {
                        if (res.code !== 200) {
                            $App.$Message(res.message, 'warning');
                            return true;
                        }
                        $App.$Message('文件上传成功！');
                        $App.GalleryParams.operation.loadingMsg = '';
                        $App.GalleryParams.operation.loading = false;
                        $App.$refs.GalleryDialogUpload.clearFiles();
                        $App.GalleryParams.search.page = 1;
                        $Gallery.GalleryRequestLists();
                        $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
                    });
                }
                break;
            // case'cos':
            //     params.group_id = $App.GalleryParams.search.group_id;
            //     params.type = $App.GalleryParams.search.type;
            //     params.code = 200;
            //     params.url = $App.GalleryParams.domain + '/' + $App.GalleryParams.postData.key;
            //     params.file_name = $App.GalleryParams.options.file_name;
            //     params.size = $App.GalleryParams.postData.size;
            //     params.driver = $App.GalleryParams.driver;
            //     params.key = $App.GalleryParams.postData.key;
            //     if (params.code === 200){
            //         $Request.postJson('framework/common/gallery/insert', params, function (res) {
            //             if (res.code !== 200) {
            //                 $App.$Message(res.message, 'warning');
            //                 return true;
            //             }
            //             $App.$Message('文件上传成功！');
            //             $App.GalleryParams.operation.loadingMsg = '';
            //             $App.GalleryParams.operation.loading = false;
            //             $App.$refs.GalleryDialogUpload.clearFiles();
            //             $App.GalleryParams.search.page = 1;
            //             $Gallery.GalleryRequestLists();
            //             $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
            //         });
            //     }
            //     break;
            default:
                $App.GalleryParams.operation.loadingMsg = '';
                $App.GalleryParams.operation.loading = false;
                $App.$refs.GalleryDialogUpload.clearFiles();
                if (response.code !== 200) {
                    $App.$Message(response.message, 'warning');
                    return true;
                } else {
                    $App.$Message('文件上传成功！');
                    $App.GalleryParams.search.page = 1;
                    $Gallery.GalleryRequestLists();
                    break;
                }
        }
    },

    GalleryUploadError: function () {
        var that = this;
        $App.$Message('文件上传失败，请重试！', 'warning');
        $App.GalleryParams.operation.loadingMsg = '';
        $App.GalleryParams.operation.loading = false;
        // that.GalleryUploadParams();
        // $App.$refs.GalleryDialogUpload.clearFiles();
    },

    GalleryUploadBefore: function (file) {
        $App.GalleryParams.size = file.size;
        return new Promise(async (resolve, reject) => {
            /*验证图片大小*/
            if ($App.GalleryParams.options.size) {
                if ((file.size / 1048576) > $App.GalleryParams.options.size) {
                    $App.$Message('请上传' + $App.GalleryParams.options.size + 'M以内的文件', 'warning');
                    $Gallery.GalleryCloseOperationLoading();
                    return reject();
                }
            }
            /*验证文件后缀*/
            if ($App.GalleryParams.options.suffix) {
                var args = ((file.name).split('.'));
                if (args[args.length - 1]) {
                    var args_suffix = (args[args.length - 1]).toLowerCase();
                    var suffix = ($App.GalleryParams.options.suffix).split(',');
                    if ($.inArray(args_suffix, suffix) < 0) {
                        $App.$Message('请上传' + $App.GalleryParams.options.suffix + '类型的文件', 'warning');
                        $Gallery.GalleryCloseOperationLoading();
                        return reject();
                    }
                }
            }
            $App.GalleryParams.options.file_name = file.name;
            $App.GalleryParams.postData.file_name = file.name;
            $App.GalleryParams.operation.loadingMsg = '文件正在上传 (0%), 请稍后...';
            $App.GalleryParams.operation.loading = true;

            await $Gallery.GalleryGetFileKey().catch(err => {
                $App.$Message('操作失败！');
                $Gallery.GalleryCloseOperationLoading();
                return reject();
            });

            switch ($App.GalleryParams.driver) {
                case 'qiniu':
                    break;
                case 'oss':
                    // console.log('oss',$App.GalleryParams.postData);
                    break;
                default:
                    break;
            }

            $App.GalleryParams.operation.error = false
            return resolve();
        })
    },

    GalleryCloseOperationLoading: function () {
        setTimeout(function () {
            $App.$refs.GalleryDialogUpload.clearFiles();
            $App.GalleryParams.operation.loadingMsg = '';
            $App.GalleryParams.operation.loading = false;
            $App.GalleryParams.operation.error = true;
            $App.GalleryParams.search.page = 1;
            $Gallery.GalleryRequestLists();
            $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
        }, 1000)
    },

    // 获取文件地址
    GalleryGetFileKey() {
        return new Promise(function (resolve, reject) {
            switch ($App.GalleryParams.driver) {
                case 'qiniu':
                case 'oss':
                case 'cos':
                    $Request.postJson('framework/common/getFileKey', $App.GalleryParams.postData, function (res) {
                        if (res.code !== 200) {
                            $App.$Message(res.message, 'warning');
                            reject()
                            return false;
                        }
                        $App.GalleryParams.postData.key = res.result.key;
                        resolve()
                    });
                    break;
                default:
                    resolve()
                    return true;
            }
        })
    },

    GalleryUploadDialogClose: function () {
        $App.GalleryParams.selected = [];
        $App.GalleryParams.operation.loadingMsg = '';
        $App.GalleryParams.operation.loading = false;
        $App.GalleryParams.operation.dialog = false;
    },

    GalleryUploadDialogSubmit: function () {
        var that = this;
        var selected = $App.GalleryParams.selected;
        if (selected.length <= 0) {
            $App.$Message('请选择文件！', 'warning');
            return false;
        }
        if (!$App.GalleryParams.options.multiple) {
            selected = selected[0];
        }

        $App.GalleryParams.options.callback(selected);
        $App.GalleryParams.selected = [];
        $App.GalleryParams.operation.loading = false;
        $App.GalleryParams.operation.dialog = false;
    },

    GalleryGroupChangeEvent: function (item) {
        $.each($App.GalleryParams.groupItems, function (key, val) {
            val.active = false;
        });
        item.active = true;
        $App.GalleryParams.imagesItems = [];
        $App.GalleryParams.search.page = 1;
        $App.GalleryParams.operation.imageTotal = 0;
        $App.GalleryParams.search.group_id = item.id;
        $Gallery.GalleryRequestLists();
    },

    GalleryGroupRemoveEvent: function (index, item) {
        $App.$Confirm('确认删除当前分组吗？', function (res) {
            $Request.postJson('framework/common/gallery/groupRemove', {
                id: item.id
            }, function (res) {
                if (res.code === 200) {
                    $App.$message({message: res.message, type: 'success', duration: 2400});
                    $Gallery.GalleryRequestLists();
                } else {
                    $App.$message({message: res.message, type: 'error', duration: 2400});
                }
            });
        });
    },

    GalleryRemotePictureEvent: function () {
        var that = this;
        $App.GalleryParams.operation.loading = true;
        $App.$prompt('', '图片地址', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            inputValue: '',
            lockScroll: false,
            inputPlaceholder: '请输入图片地址',
            inputValidator: function (e) {
                return $Validator.image(e);
            },
            inputErrorMessage: '请输入图片地址',
        }).then(function (result) {

            if (!result.value) {
                $App.$message({type: 'error', message: '请输入图片地址！'});
                return false;
            }
            $App.GalleryParams.postData._value = result.value;
            $Request.postJson('framework/common/gallery/remote', $App.GalleryParams.postData, function (res) {
                if (res.code === 200) {
                    $App.$message({message: '图片保存成功！', type: 'success', duration: 2400});
                    $Gallery.GalleryRequestLists();
                    that.GalleryUploadParams();
                } else {
                    $App.$message({message: res.message, type: 'error', duration: 2400});
                }
                $App.GalleryParams.operation.loading = false;
            });
        }).catch(function () {
            $App.GalleryParams.operation.loading = false;
        });
    },

    GalleryAddPageEvent: function (item, is_update) {
        var params = {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            lockScroll: false,
            inputPlaceholder: '网页地址规则：网页名称，网页地址',
            inputErrorMessage: '请输入图片地址',
        };
        if (is_update && item.id) {
            params.inputValue = item.original + ',' + item.url;
        }
        $App.$prompt('', '网页地址', params).then(function (result) {
            if (!result.value) {
                $App.$message({type: 'error', message: '请输入网页地址！'});
                return false;
            }
            $App.GalleryParams.postData._value = result.value;
            if (is_update && item.id) {
                $App.GalleryParams.postData._id = item.id;
                $App.GalleryParams.postData._is_update = 1;
            }
            $App.GalleryParams.postData._value = result.value;
            $Request.postJson('framework/common/gallery/pages', $App.GalleryParams.postData, function (res) {
                if (res.code === 200) {
                    $App.$message({message: res.message, type: 'success', duration: 2400});
                    $Gallery.GalleryRequestLists();
                } else {
                    $App.$message({message: res.message, type: 'error', duration: 2400});
                }
            });
        }).catch(function () {
        });
    },

    GalleryItemUpdateOriginalEvent: function (item) {
        $App.$prompt('', '修改文件名', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            inputPlaceholder: '请输入文件名',
            inputValue: item.original,
            lockScroll: false,
            closeOnClickModal: false,
        }).then(function (params) {
            if (!params.value) {
                $App.$message({message: '请输入文件名！', type: 'error', duration: 2400});
            } else {
                $Request.postJson('framework/common/gallery/original', {
                    id: item.id, name: params.value
                }, function (res) {
                    if (res.code === 200) {
                        $App.$message({message: '文件名修改成功！', type: 'success', duration: 2400});
                        $Gallery.GalleryRequestLists();
                    } else {
                        $App.$message({message: '文件名修改失败，请稍后再试！', type: 'error', duration: 2400});
                    }
                })
            }
        }).catch(function () {
        });
    },

    GalleryItemRemoveEvent: function (item) {
        $App.$confirm('确认删除当前数据吗？删除后不可恢复！', '操作提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            dangerouslyUseHTMLString: true,
            lockScroll: false,
            center: true
        }).then(function () {
            $Request.postJson('framework/common/gallery/remove', {
                id: item.id
            }, function (res) {
                if (res.code === 200) {
                    $App.$message({message: '文件删除成功！', type: 'success', duration: 2400});
                    $Gallery.GalleryRequestLists();
                } else {
                    $App.$message({message: '文件删除失败，请稍后再试！', type: 'error', duration: 2400});
                }
            })
        }).catch(function () {
        });
    },

    GalleryTabEvent: function () {
        $Gallery.GalleryUploadToken($App.GalleryParams.options.type);
        $Gallery.GalleryUploadInit();
    },

    GalleryGroupUpdateEvent: function (index, item) {
        $App.$prompt('', '修改分组', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            inputValue: item.name,
            lockScroll: false,
            inputPlaceholder: '请输入分组名称',
            inputValidator: function (e) {
                return (e && e.length < 10) ? true : false;
            },
            inputErrorMessage: '请输入分组名称',
        }).then(function (result) {
            if (!result.value) {
                $App.$message({type: 'error', message: '请输入分组名称！'});
                return false;
            }
            $Request.postJson('framework/common/gallery/groupUpdate', {
                id: item.id,
                name: result.value
            }, function (res) {
                if (res.code === 200) {
                    $App.$message({message: res.message, type: 'success', duration: 2400});
                    $Gallery.GalleryRequestLists();
                } else {
                    $App.$message({message: res.message, type: 'error', duration: 2400});
                }
            });
        }).catch(function () {
        });
    },

    GalleryGroupInsertEvent: function () {
        if ($App.GalleryParams.groupItems.length > 6) {
            $App.$message({message: '分组最多可添加5个!', type: 'error', duration: 2400});
            return false;
        }
        $App.$prompt('', '添加分组', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            lockScroll: false,
            inputPlaceholder: '请输入分组名称，最长10个字符',
            inputValidator: function (e) {
                return (e && e.length < 10) ? true : false;
            },
            inputErrorMessage: '请输入分组名称',
        }).then(function (result) {
            if (!result.value) {
                $App.$message({type: 'error', message: '请输入分组名称！'});
                return false;
            }
            $Request.postJson('framework/common/gallery/groupCreate', {
                name: result.value,
                type: $App.GalleryParams.options.type
            }, function (res) {
                if (res.code === 200) {
                    $App.$message({message: res.message, type: 'success', duration: 2400});
                    $Gallery.GalleryRequestLists();
                } else {
                    $App.$message({message: res.message, type: 'error', duration: 2400});
                }
            });
        }).catch(function () {
        });
    },

    GalleryGroupManageEvent: function () {
        $App.GalleryParams.operation.groupManage = !$App.GalleryParams.operation.groupManage;
    },

    GalleryImagesPageChange: function (page) {
        var that = this;
        $App.GalleryParams.search.page = page;
        $Gallery.GalleryRequestLists();
    },

    GalleryItemCheckboxEvent: function (item) {
        var that = this;
        // console.log(11111,item);
        if (item.active === 0 || item.active === false) {
            /*多选*/
            if ($App.GalleryParams.options.max > 1) {
                if ($App.GalleryParams.selected.length >= $App.GalleryParams.options.max) {
                    $App.$message({
                        message: '最多可选择' + $App.GalleryParams.options.max + '项！',
                        type: 'warning'
                    });
                    return true;
                } else {
                    item.active = true;
                    $App.GalleryParams.selected.push(item);
                }
            } else {
                if ($App.GalleryParams.selected.length > 0) {
                    $App.GalleryParams.selected.forEach(function (selected_item) {
                        $App.GalleryParams.imagesItems.forEach(function (rows, index) {
                            if (selected_item.id === rows.id) {
                                rows.active = false;
                            }
                        });
                    });
                }
                item.active = true;
                $App.GalleryParams.selected = [];
                $App.GalleryParams.selected[0] = item;
            }
        } else {
            $Gallery.GalleryItemActiveInEvent(item);
        }
    },

    GalleryItemActiveInEvent: function (item) {
        /*取消选中*/
        if ($App.GalleryParams.options.max > 1) {
            if ($App.GalleryParams.selected.length > 0) {
                $App.GalleryParams.selected.forEach(function (rows, index) {
                    if (rows.id === item.id) {
                        $App.GalleryParams.selected.splice(index, 1);
                        item.active = false;
                        return true;
                    }
                });
            } else {
                item.active = false;
                $App.GalleryParams.selected = [];
                return true;
            }
        } else {
            item.active = false;
            $App.GalleryParams.selected = [];
            return true;
        }
    },

    GalleryItemDropdownEvent: function (e, item) {
        var that = this;
        if (e.target.dataset.command === 'edit') {
            that.GalleryItemUpdateOriginalEvent(item);
        } else {
            that.GalleryItemRemoveEvent(item);
        }
    },

    GalleryRequestLists: function () {
        $App.GalleryParams.operation.loading = true;
        $App.GalleryParams.operation.groupManage = false;
        $Gallery.GalleryUploadParams();
        $Gallery.GalleryGroupRequestLists();
        $Request.postJson('framework/common/gallery/iframe', $App.GalleryParams.search, function (res) {
            if (res.code === 200) {
                $App.GalleryParams.imagesItems = res.result.data;
                $App.GalleryParams.operation.imageTotal = res.result.total;
                $App.GalleryParams.selected.forEach(function (selected_item) {
                    $App.GalleryParams.imagesItems.forEach(function (item, index) {
                        if (selected_item.id === item.id) {
                            item.active = true;
                        }
                    });
                });
            }
            $App.GalleryParams.operation.loadingMsg = '';
            $App.GalleryParams.operation.loading = false;
            $App.layouts.dialogFormsHeight = {
                'max-height': parseInt((document.documentElement.clientHeight * 0.75) - 120) + 'px'
            };
            // console.log($App.layouts.dialogFormsHeight)
        });
    },

    GalleryGroupRequestLists: function () {
        $App.GalleryParams.loading = true;
        $Request.postJson('framework/common/gallery/group', $App.GalleryParams.search, function (res) {
            if (res.code === 200) {
                $App.GalleryParams.groupItems = res.result;
            }
        });
    },
};
window.$Center = {
    CenterDialogOpen: function () {
        $App.CenterParams.loadingMsg = '正在加载数据，请稍后...';
        $App.CenterParams.loading = true;
        $App.CenterParams.dialog = true;
        $App.CenterParams.model = {name:'',account:'',password:''};
        $Request.postJson('framework/common/center/info', {}, function (res) {
            if(res.code === 200){
                $App.CenterParams.model = res.result;
                $App.CenterParams.loading = false;
            } else {
                $App.$message({message: res.message, type: 'error'});
                $App.CenterParams.loadingMsg = res.message;
            }
        })
    },
    CenterDialogClose: function () {
        $App.CenterParams.dialog = false;
    },
    CenterDialogSubmits: function (){
        $App.CenterParams.loadingMsg = '正在提交，请稍后...';
        $App.CenterParams.loading = true;
        var params = $App.CenterParams.model;
        $Request.postJson('framework/common/center/update', params, function (res) {
            if(res['code'] === 200) {
                $App.$Message(res['message'], function () {
                    $App.CenterParams.loading = false;
                    $App.CenterParams.dialog = false;
                    location.reload();
                });
            } else {
                $App.$Message(res.message, 'error');
            }
        });
    },
    // 监测抽屉鼠标事件
    handleWrapperMousedown(e) {
        // 如果为true，则表示点击发生在遮罩层
        $App.CenterParams.dialogClassModel = !!e.target.classList.contains('el-dialog__wrapper')
    },
    handleWrapperMouseup(e) {
        if ((!!e.target.classList.contains('el-dialog__wrapper')) && $App.CenterParams.dialogClassModel) {
            $App.CenterParams.dialog = false;
        }
    },
    // 监测抽屉鼠标事件 End.
};
window.$Arrays = {
    /*  arrayLookup(data,'id',1,'name');*/
    arrayLookup: function (data, key, value, targetKey) {
        if (!data) return '---';
        var data_length = data.length;
        var targetValue = "";
        for (var i = 0; i < data_length; i++) {
            if (!data[i][key]) {
                break;
            }
            if (data[i][key] == value) {
                targetValue = targetKey ? data[i][targetKey] : data[i];
                break;
            }
        }
        return targetValue ? targetValue : '---';
    }
};

// 自定义模板
Vue.component('va-media', {
    props: {
        size: {type: Number, default: 20},
        file: {type: String, default: ''},
        width:{ type: String, default: '400px'},
        height:{ type: String, default: '240px'}
    },

    model: {
        prop: 'file',
        event: 'change'
    },
    template: '<div style="border: 1px dashed #2d8cf0;border-radius: 5px;cursor: pointer" :style="{\'width\':width,\'height\':height}" @click="pictureGalleryOpen">' +
        '<img src="/statics/v1/image/empty/data.png" style="width: 100%;height: 100%;object-fit: contain;" v-if="!file">' +
        '<video :src="file" :poster="file+\'?vframe/jpg/offset/2/w/130/h/140/\'" ' +
        'controls="controls" width="100%" height="100%" autoplay v-if="file">' +
        '<source :src="file" type="video/mp4" /></video></div>',
    methods: {
        pictureGalleryOpen: function() {
            var that = this;
            $Gallery.GalleryDialogOpen({
                max: 1,
                size: that.size,
                multiple: false,
                type: 2,
                cat:true,
                callback: function(res) {
                    that.$emit('change', res.url);
                }
            });
        }
    },
    mounted: function() {

    }
});
Vue.component('va-image', {
    props: {
        size: {type: Number, default: 20},
        src: {type: String, default: ''},
        key: {type: String, default: ''}
    },
    data: function () {
        return {
            imageUrl: '',
            imageUrlList: [],
        };
    },
    watch: {
        src(value) {
            if (!this.imageUrl) {
                this._init(value);
            }
        },
    },
    template: '<el-image class="tables-image" :src="imageUrl" fit="contain" lazy :size="size" :key="key" :preview-src-list="imageUrlList">' +
        '<div slot="error" class="image-slot"><i class="fa fa-picture-o"></i></div>' +
        '</el-image>',
    methods: {
        _init: function (value) {
            var that = this;
            if (!value) {
                that.imageUrl = '/statics/v1/image/common/empty.jpeg';
                return true;
            }
            if ($Validator.json(value)) {
                var fileItems = JSON.parse(value);
                if (fileItems.length && fileItems.length > 0) {
                    $.each(fileItems, function (key, item) {
                        that.imageUrlList.push(item.url ? item.url : item);
                    });
                    that.imageUrl = that.imageUrlList[0];
                } else {
                    that.imageUrl = fileItems.url ? fileItems.url : fileItems;
                }
            } else {
                if (value.includes('base64')){
                    that.imageUrlList = [value];
                }else {
                    that.imageUrlList = value.split(",").filter(function (n) {
                        return n
                    });
                }
                if (that.imageUrlList.length < 1) {
                    that.imageUrl = '/statics/v1/image/common/empty.jpeg';
                } else {
                    that.imageUrl = that.imageUrlList[0];
                }
            }
        }
    },
    mounted: function () {
        this._init(this.src);
    }
});
Vue.component('va-forms-tips', {
    props: {},
    data: function () {
        return {};
    },
    template: '<span class="Va-help-block" data-7512a93d><i class="el-icon-info"></i>  <slot></slot></span>',
    mounted: function () {

    }
});
Vue.component("va-picture", {
    props: {
        action: {
            type: String,
            default: 'framework/common/pictureUploads'
        },
        size: {
            type: Number,
            default: 20
        },
        suffix: {
            type: String,
            default: 'png,bmp,jpeg,jpg,gif'
        },
        postData: {
            type: Object,
            default: {}
        },
        file: {
            type: String,
            default: ''
        },
        gallery: {
            type: Boolean,
            default: true
        },
        alt: {
            type: Boolean,
            default: false
        },
        name: {
            type: Boolean,
            default: false
        },
        disabled: {
            type: Boolean,
            default: false
        },
        onSuccess: {
            type: Function,
            default: function (res) {
            }
        },

    },

    data: function () {
        return {
            picture: {
                postHeaders: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                uploadStatus: false,
                progress: 0,
            },
            fileItems: {
                url: '',
                alt: '',
                name: ''
            },
            _fileName: '', _fileSize: 0,
            galleryOptions: {},
            uploadOption: {driver: 'local', action: '', token: '', domain: ''},
        }
    },

    model: {
        prop: 'file',
        event: 'change'
    },
    computed: {
        fileItemsAlt() {
            return this.fileItems.alt;
        },
        fileItemsName() {
            return this.fileItems.name;
        }
    },
    watch: {
        file(value) {
            var that = this;

            if (that.alt || that.name) {
                if ($Validator.json(value)) {
                    that.fileItems = JSON.parse(value);
                }
            } else {
                that.fileItems = {
                    url: value,
                    alt: '',
                    name: ''
                };
            }
        },

        fileItemsAlt(value) {
            this.emitItemsEvent()
        },
        fileItemsName(value) {
            this.emitItemsEvent()
        },
    },

    template: '<div v-if="!fileItems.url" :disabled="disabled">\n' +
        '  <el-upload\n' +
        '          :action="action"\n' +
        '          :show-file-list="false"\n' +
        '          :headers="picture.postHeaders"\n' +
        '          :data="postData"\n' +
        '          :on-success="pictureUploadSuccess"\n' +
        '          :on-progress="pictureUploadProgress"\n' +
        '          :on-change="pictureChangeEvent"\n' +
        '          :on-error="pictureUploadError"\n' +
        '          ref="pictureUploadRef"\n' +
        '          :disabled="disabled"\n' +
        '          :before-upload="pictureUploadBefore" v-if="!gallery">\n' +
        '      <div class="va-component-picture" :disabled="disabled" v-if="!picture.uploadStatus">\n' +
        '          <div class="upload" :disabled="disabled">\n' +
        '              <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
        '          </div>\n' +
        '      </div>\n' +
        '      <div class="va-component-picture" v-else :disabled="disabled">\n' +
        '          <el-progress type="circle" :percentage="picture.progress" style="margin-top: 5px;" ></el-progress>\n' +
        '      </div>\n' +
        '  </el-upload>\n' +
        '  <div v-else class="va-component-picture gallery" :disabled="disabled" @click="pictureGalleryOpen">\n' +
        '      <div class="upload" :disabled="disabled">\n' +
        '          <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
        '      </div>\n' +
        '  </div>\n' +
        '</div>\n' +
        '<div class="va-component-picture" v-else :disabled="disabled">\n' +
        '    <div class="show" :title="fileItems.alt">\n' +
        '        <el-image class="image" :src="fileItems.url"></el-image>\n' +
        '        <div class="shadow" v-if="!disabled">\n' +
        '            <i class="el-icon-delete icon" @click="pictureItemsRemove(fileItems)"></i>\n' +
        '            <el-dropdown class= "dropdown-picture-edit" placement="top" size="mini" style="position：absolute" @command="pictureItemsEdit(event)" v-if="alt || name">\n' +
        '               <span class="el-dropdown-link"><i class="el-icon-edit icon"></i> </span>\n' +
        '             <el-dropdown-menu slot="dropdown">\n' +
        '               <el-dropdown-item command="name" data-command="name" v-if="name">名称</el-dropdown-item>\n' +
        '               <el-dropdown-item command="alt" data-command="alt" v-if="alt">alt</el-dropdown-item>\n' +
        '  </el-dropdown-menu></el-dropdown>\n' +
        '        </div>\n' +
        '    </div>\n' +
        '</div>',
    methods: {
        pictureGalleryOpen: function () {
            var that = this;
            if (that.disabled) {
                return false;
            }
            $Gallery.GalleryDialogOpen({
                max: 1,
                size: that.size,
                suffix: that.suffix,
                multiple: false,
                type: '1',
                tabs: false,
                callback: function (res) {
                    that.fileItems = {url: res.url, alt: res.original, name: res.original};
                    that.emitItemsEvent();
                    that.picture.uploadStatus = false;
                    that.picture.progress = 0;
                }
            });
        },

        pictureItemsEdit: function (e, item, index) {
            var that = this;
            if (that.disabled) {
                return false;
            }
            var tips = (e.target.dataset.command === 'name') ? '名称' : 'alt';
            $App.$prompt('', '修改图片' + tips, {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPlaceholder: '请输入图片' + tips,
                inputValue: that.fileItems[e.target.dataset.command],
                lockScroll: false,
            }).then(function (params) {
                if (!params.value) {
                    $App.$message({
                        message: '请输入图片' + tips,
                        type: 'error',
                        duration: 2400
                    });
                } else {
                    that.fileItems[e.target.dataset.command] = params.value;
                    that.emitItemsEvent();
                }
            }).catch(function () {
            });
            return true;
        },

        pictureItemsRemove: function () {
            var that = this;
            that.fileItems = {
                url: '',
                alt: '',
                name: ''
            };
            that.emitItemsEvent();
        },

        pictureAltEvent: function (items, index) {
            var that = this;
            that.$refs[('picturePopoverAlt00101')].doClose();
        },

        pictureUploadProgress: function (event, file, fileList) {
            var that = this;
            that.picture.progress = parseFloat((event.percent).toFixed(2));
        },

        pictureUploadSuccess: function (response, file, fileList) {
            var that = this;
            var url;
            that.$refs.pictureUploadRef.clearFiles();
            if (response.code !== 200) {
                switch (that.uploadOption.driver) {
                    case 'qiniu':
                        response.url = that.uploadOption.domain + '/' + response.key;
                        url = response.url;
                        that.onSuccess(response);
                        break;
                    case'oss':
                    default:
                        url = response.result.url;
                        $App.$Message(response.msg, 'warning');
                        that.picture.uploadStatus = false;
                        that.picture.progress = 0;
                        break;
                }
                that.fileItems = {
                    url: url,
                    alt: that.fileItems.alt,
                    name: that.fileItems.name,
                    defaultImg: that.uploadOption.defaultImg
                };
                that.emitItemsEvent();
                $App.$Message('文件上传成功！', 'success');
                that.picture.uploadStatus = false;
                that.picture.progress = 0;
                return true;
            } else {
                $App.$Message(response.msg, 'warning');
                that.picture.uploadStatus = false;
                that.picture.progress = 0;
            }
        },

        pictureUploadError: function () {
            var that = this;
            that.picture.uploadStatus = false;
            that.picture.progress = 0;
            $App.$Message('文件上传失败，请重试！', 'warning');
            that.$refs.pictureUploadRef.clearFiles();
            return true;
        },

        pictureUploadBefore: function (file, e) {
            var that = this;
            /*验证图片大小*/
            if (that.size) {
                if ((file.size / 1048576) > that.size) {
                    $App.$Message('请上传' + that.size + 'M以内的文件', 'warning');
                    that.$refs.pictureUploadRef.clearFiles();
                    return false;
                }
            }

            /*验证文件后缀*/
            if (that.suffix) {
                var args = ((file.name).split('.'));
                if (args[args.length - 1]) {
                    var suffix = (that.suffix).split(',');
                    if ($.inArray((args[args.length - 1]).toLowerCase(), suffix) < 0) {
                        $App.$Message('请上传' + that.suffix + '类型的文件', 'warning');
                        that.$refs.pictureUploadRef.clearFiles();
                        return false;
                    }
                }
            }
            that._fileSize = (file.size / 1048576).toFixed(2);
            that._fileName = file.name;
            that.picture.uploadStatus = true;
            that.picture.progress = 1;
            return true;
        },

        emitItemsEvent: function () {
            var that = this;
            if (that.alt || that.name) {
                that.$emit('change', JSON.stringify(that.fileItems));
            } else {
                that.$emit('change', that.fileItems.url);
            }
            that.UploadToken();
        },

        UploadToken: function () {
            var that = this;
            if (that.gallery) return true;
            $Gallery.GalleryUploadToken(function (res) {
                that.uploadOption.driver = res.result.driver;
                that.uploadOption.domain = res.result.domain;
                that.action = res.result.action;
                that.postData.token = res.result.token;
                if (res.result.key) {
                    $App.postData.key = res.result.key;
                }
                if (res.result.driver === 'local') {
                    $App.action = 'framework/common/pictureUploads';
                }
            }, 1)
        }
    },

    mounted: function () {
        var that = this;
        that.UploadToken();
        if (!that.size) {
            that.postData.size = 20;
        } else {
            that.postData.size = that.size;
        }
        if (!that.suffix) {
            that.postData.suffix = 'png,bmp,jpeg,jpg,gif';
        } else {
            that.postData.suffix = that.suffix;
        }
        if (that.alt) {
            if (that.file) {
                if ((typeof that.file) == 'object') {
                    that.fileItems = that.file;
                } else {
                    if (!$Validator.json(that.file)) {
                        console.error('va-picture components. File parameter requires a JSON string');
                    } else {
                        that.fileItems = JSON.parse(that.file);
                    }
                }
            } else {
                that.fileItems = {
                    url: '',
                    alt: ''
                };
            }
        } else {
            that.fileItems = {
                url: (that.file && that.file != 'null') ? that.file : '',
                alt: '',
                name: ''
            };
        }

        that.galleryOptions = {
            max: 1,
            size: that.size,
            suffix: that.suffix,
            type: 'image',
            callback: 'pictureSelectedSuccess'
        };
        that.picture.uploadStatus = false;
        that.picture.progress = 0;
    }
});
Vue.component("va-picture-multiple", {
    props: {
        action: {
            type: String,
            default: 'framework/common/pictureUploads'
        },
        size: {
            type: Number,
            default: 20
        },
        suffix: {
            type: String,
            default: 'png,bmp,jpeg,jpg,gif'
        },
        postData: {
            type: Object,
            default: {}
        },
        limit: {
            type: Number,
            default: 10
        },
        file: {
            type: String,
            default: ''
        },
        gallery: {
            type: Boolean,
            default: true
        },
        alt: {
            type: Boolean,
            default: false
        },
        name: {
            type: Boolean,
            default: false
        },
        disabled: {
            type: Boolean,
            default: false
        },
    },

    data: function () {
        return {
            picture: {
                postHeaders: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                uploadStatus: false,
                progress: 0,
            },
            fileItems: [],
            galleryOptions: {},
            uploadOption: {driver: 'local', action: '', token: '', domain: ''},
        }
    },

    model: {
        prop: 'file',
        event: 'change'
    },

    watch: {
        file(value) {
            if (this.fileItems && this.fileItems.length > 0) {
                return true;
            }
            this.formatFileEvent(value);
        }
    },
    template: '<div class="va-component-picture-multiple" :disabled="disabled" id="_va-component-picture">\n' +
        '    <template v-if="fileItems.length > 0" >\n' +

        '           <div v-for="(item, index) in fileItems" class="va-component-picture picture__Sortable" :data-no="index" :disabled="disabled">\n' +
        '               <div class="show" :title="item.alt">\n' +
        '                   <img class="image" :src="item.url">\n' +
        '                       <div class="shadow" v-if="!disabled">\n' +
        '                           <i class="el-icon-delete icon" @click="pictureItemsRemove(item, index)"></i>\n' +
        '                               <el-dropdown class= "dropdown-picture-edit" placement="top" style="position：absolute" size="mini" @command="pictureItemsEdit(event, item, index)" v-if="alt || name">\n' +
        '                                   <span class="el-dropdown-link"><i class="el-icon-edit icon"></i> </span>\n' +
        '                                   <el-dropdown-menu slot="dropdown">\n' +
        '                                       <el-dropdown-item command="name" data-command="name" v-if="name">名称</el-dropdown-item>\n' +
        '                                       <el-dropdown-item command="alt" data-command="alt" v-if="alt">alt</el-dropdown-item>\n' +
        '                                   </el-dropdown-menu>' +
        '                               </el-dropdown>\n' +
        '                       </div>\n' +
        '                   </div>\n' +
        '           </div>' +

        '    </template>\n' +
        '    <template v-if="fileItems.length < limit">\n' +
        '        <el-upload\n' +
        '                :action="action"\n' +
        '                :show-file-list="false"\n' +
        '                :headers="picture.postHeaders"\n' +
        '                :data="postData"\n' +
        '                :multiple="true"\n' +
        '                :limit="limit"\n' +
        '                :on-success="pictureUploadSuccess"\n' +
        '                :on-progress="pictureUploadProgress"\n' +
        '                :on-error="pictureUploadError"\n' +
        '                ref="pictureMultipleUploadRef"\n' +
        '                :before-upload="pictureUploadBefore" v-if="!gallery">\n' +
        '            <div class="va-component-picture" :disabled="disabled" v-if="!picture.uploadStatus" >\n' +
        '                <div class="upload" :disabled="disabled">\n' +
        '                    <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
        '                </div>\n' +
        '            </div>\n' +
        '            <div class="va-component-picture" :disabled="disabled" v-else>\n' +
        '                <el-progress type="circle" :percentage="picture.progress" style="margin-top: 10px;" ></el-progress>\n' +
        '            </div>\n' +
        '        </el-upload>\n' +
        '        <div v-else class="va-component-picture gallery" :disabled="disabled" @click="pictureGalleryOpen">\n' +
        '            <div class="upload" :disabled="disabled">\n' +
        '                <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
        '            </div>\n' +
        '        </div>\n' +
        '    </template>\n' +
        '</div>',

    methods: {
        pictureGalleryOpen: function () {
            var that = this;
            if (that.disabled) {
                return false;
            }
            $Gallery.GalleryDialogOpen({
                max: (that.limit - that.fileItems.length),
                size: that.size,
                suffix: that.suffix,
                multiple: true,
                type: '1',
                tabs: false,
                callback: function (res) {
                    res.forEach(function (item, key) {
                        if (that.fileItems.length < 1) {
                            that.fileItems.push({url: item.url, alt: item.original, name: item.original});
                        } else {
                            if (that.fileItems.length < that.limit) {
                                that.fileItems.push({url: item.url, alt: item.original, name: item.original});
                            }
                        }
                    });
                    that.emitItemsEvent();
                    that.picture.uploadStatus = false;
                    that.picture.progress = 0;
                }
            });
        },

        pictureItemsEdit: function (e, item, index) {
            var that = this;
            if (that.disabled) {
                return false;
            }
            var tips = (e.target.dataset.command === 'name') ? '名称' : 'alt';
            $App.$prompt('', '修改图片' + tips, {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPlaceholder: '请输入图片' + tips,
                inputValue: item[e.target.dataset.command],
                lockScroll: false,
            }).then(function (params) {
                if (!params.value) {
                    $App.$message({
                        message: '请输入图片' + tips,
                        type: 'error',
                        duration: 2400
                    });
                } else {
                    item[e.target.dataset.command] = params.value;
                    that.emitItemsEvent();
                }
            }).catch(function(){});
            return true;
        },
        pictureItemsRemove: function (items, index) {
            var that = this;
            that.fileItems.splice(index, 1);
            that.emitItemsEvent();
        },
        pictureUploadProgress: function (event, file, fileList) {
            var that = this;
            that.picture.progress = parseFloat((event.percent).toFixed(2));
        },
        pictureUploadSuccess: function (response, file, fileList) {
            var that = this;
            var fileItemsMaps = that.fileItems;
            var url;
            switch (that.uploadOption.driver) {
                case 'qiniu':
                    url = that.uploadOption.domain + '/' + response.key;
                    break;
                case'oss':
                default:
                    if (response.code !== 200) {
                        $App.$Message(response.msg, 'warning');
                        that.picture.uploadStatus = false;
                        that.picture.progress = 0;
                        return true;
                    } else {
                        url = response.result.url;
                    }
                    break;
            }
            if (fileItemsMaps.length < that.limit) {
                fileItemsMaps.push({url: url, alt: '', name: ''});
            }
            ;
            that.fileItems = fileItemsMaps;
            that.emitItemsEvent();
            $App.$Message('文件上传成功！', 'success');
            that.picture.uploadStatus = false;
            that.picture.progress = 0;
            return true;
        },

        pictureUploadError: function () {
            var that = this;
            that.picture.uploadStatus = false;
            that.picture.progress = 0;
            $App.$Message('文件上传失败，请重试！', 'warning');
            that.$refs.pictureMultipleUploadRef.clearFiles();
            return true;
        },
        pictureUploadBefore: function (file, e) {
            var that = this;
            that.UploadToken();
            /*验证图片大小*/
            if (that.size) {
                if ((file.size / 1048576) > that.size) {
                    $App.$Message('请上传' + that.size + 'M以内的文件', 'warning');
                    that.$refs.pictureMultipleUploadRef.clearFiles();
                    return false;
                }
            }

            /*验证文件后缀*/
            if (that.suffix) {
                var args = ((file.name).split('.'));
                if (args[args.length - 1]) {
                    var suffix = (that.suffix).split(',');
                    if ($.inArray((args[args.length - 1]).toLowerCase(), suffix) < 0) {
                        $App.$Message('请上传' + that.suffix + '类型的文件', 'warning');
                        that.$refs.pictureMultipleUploadRef.clearFiles();
                        return false;
                    }
                }
            }
            that.picture.uploadStatus = true;
            that.picture.progress = 1;
            return true;
        },
        emitItemsEvent: function () {
            var that = this;
            that.UploadToken();
            if (that.alt || that.name) {
                that.$emit('change', JSON.stringify(that.fileItems));
                that.SortTableEvent();
            } else {
                var fileItems = '';
                if (that.fileItems.length > 0) {
                    that.fileItems.forEach(function (item, key) {
                        if (key === that.fileItems.length) {
                            fileItems += item.url;
                        } else {
                            fileItems += item.url + ',';
                        }
                    });
                    that.SortTableEvent();
                }
                that.$emit('change', fileItems);
            }
        },

        formatFileEvent: function () {
            var that = this;
            if (that.alt || that.name) {
                if (that.file) {
                    if ((typeof that.file) == 'object') {
                        that.fileItems = that.file;
                    } else {
                        if (!$Validator.json(that.file)) {
                            console.info('va-picture-multiple components. File parameter requires a JSON string');
                        } else {
                            that.fileItems = JSON.parse(that.file);
                            that.emitItemsEvent();
                        }
                    }
                } else {
                    that.fileItems = [];
                }
            } else {
                if (!that.file || that.file == '[]' || that.file == '{}') {
                    that.fileItems = [];
                } else {
                    if (that.file) {
                        if ($Validator.json(that.file)) {
                            var fileItems = JSON.parse(that.file);
                            console.log(fileItems)
                            if (fileItems.length && fileItems.length > 0) {
                                fileItems.forEach(function (item) {
                                    that.fileItems.push({
                                        url: item,
                                        alt: ''
                                    });
                                })
                                that.emitItemsEvent();
                            } else {
                                that.fileItems = [];
                            }
                        } else {
                            var fileItems = (that.file).split(',');

                            if (fileItems && fileItems.length > 0) {
                                for (var i = 0; i <= fileItems.length; i++) {
                                    if (fileItems[i]) {
                                        that.fileItems.push({
                                            url: fileItems[i],
                                            alt: ''
                                        });
                                    }
                                }
                                that.emitItemsEvent();
                            } else {
                                that.fileItems = [];
                            }
                        }

                    } else {
                        that.fileItems = [];
                    }
                }
            }
        },

        UploadToken: function () {
            var that = this;
            if (that.gallery) return true;

            $Gallery.GalleryUploadToken(function (res) {
                that.uploadOption.driver = res.driver;
                that.uploadOption.domain = res.domain;
                that.action = res.action;
                that.postData.token = res.token;
                if (res.key) {
                    that.postData.key = res.key;
                }
                if (res.driver === 'local') {
                    that.action = 'framework/common/pictureUploads';
                }
            }, 1);
        },

        SortTableEvent: function () {
            //获取对象
            var that = this;
            var el = document.getElementById('_va-component-picture');
            //设置配置
            var ops = {
                animation: 1000,
                dataIdAttr: "data-no",
                draggable: ".picture__Sortable",
                //拖动结束
                onEnd: function (evt) {
                    var asd = [];
                    var sortableArr = sortable.toArray();
                    $.each(sortableArr, function (key, val) {
                        asd.push(that.fileItems[val]);
                    });
                    that.fileItems = asd;
                    that.emitItemsEvent();
                },
            };
            //初始化
            var sortable = Sortable.create(el, ops);

        }
    },

    mounted: function () {
        var that = this;
        that.UploadToken();
        if (!that.size) {
            that.postData.size = 20;
        } else {
            that.postData.size = that.size;
        }
        if (!that.suffix) {
            that.postData.suffix = 'png,bmp,jpeg,jpg,gif';
        } else {
            that.postData.suffix = that.suffix;
        }

        that.formatFileEvent();

        that.galleryOptions = {
            max: that.limit,
            size: that.size,
            suffix: that.suffix,
            type: 'image',
            callback: 'pictureSelectedSuccess'
        };
        that.picture.uploadStatus = false;
        that.picture.progress = 0;
    }
});
Vue.component("va-video", {
    props: {
        action: {
            type: String,
            default: 'framework/common/fileUploads'
        },
        size: {
            type: Number,
            default: 20
        },
        suffix: {
            type: String,
            default: 'mp3,wma,avi,rm,rmvb,flv,mpg,mov,mk,mp4'
        },
        postData: {
            type: Object,
            default: {
                size: 20,
                suffix: 'mp3,wma,avi,rm,rmvb,flv,mpg,mov,mk,mp4'
            }
        },
        file: {
            type: String,
            default: "{url:'', size:'', original:''}"
        },
        gallery: {
            type: Boolean,
            default: true
        },
        preview: {
            type: Boolean,
            default: false
        },
        disabled: {
            type: String,
            default: false
        },
        onSuccess: {
            type: String,
            default: ''
        },
    },

    data: function () {
        return {
            postHeaders: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            uploadOption: {driver: 'local', domain: ''},
            uploadStatus: false,
            _fileName: '',
            _fileSize: 0,
            percentage: 0,
            fileItems: {url: '', size: '', original: ''},
            galleryOptions: {}
        }
    },

    model: {
        prop: 'file',
        event: 'change'
    },

    watch: {
        file(value) {
            if (!this.fileItems.url) {
                this.fileItems = JSON.parse(value);
                this.$emit('change', JSON.stringify(this.fileItems));
            }
        }
    },
    template: '<div class="va-component-file" :disabled="disabled">\n' +
        '    <el-upload\n' +
        '            v-if="!fileItems.url && !uploadStatus && !gallery"\n' +
        '            :action="action"\n' +
        '            :headers="postHeaders"\n' +
        '            limit="1"  drag\n' +
        '            :show-file-list="false"\n' +
        '            :data="postData"\n' +
        '            :disabled="disabled"\n' +
        '            :on-progress="fileUploadProgress"\n' +
        '            :on-success="fileUploadSuccess"\n' +
        '            :on-error="fileUploadError"\n' +
        '            :before-upload="fileUploadBefore"\n' +
        '            ref="fileDialogUpload"\n' +
        '    >\n' +
        '        <div class="upload">\n' +
        '            <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
        '            <div class="el-upload__text" style="margin-top: -12px">\n' +
        '                <el-link type="primary" :underline="false">\n' +
        '                    <span style="font-weight: 500;font-size: 15px">点击视频上传</span>\n' +
        '                </el-link>\n' +
        '                <div style="font-size: 12px;margin-top:-15px">\n' +
        '                    <div style="color: #909399;height: 15px">视频大小{{size}}MB以内</div>\n' +
        '                    <div style="color: #909399;height: 15px">支持类型：{{suffix}}</div>\n' +
        '                </div>\n' +
        '            </div>\n' +
        '        </div>\n' +
        '    </el-upload>\n' +
        '    <div class="upload" @click="fileGalleryOpen" v-if="!fileItems.url && !uploadStatus && gallery">\n' +
        '        <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
        '        <div class="el-upload__text" style="margin-top: -12px">\n' +
        '            <el-link type="primary" :disabled="disabled" :underline="false">\n' +
        '                <span style="font-weight: 500;font-size: 15px">点击视频上传</span>\n' +
        '            </el-link>\n' +
        '            <div style="font-size: 12px;margin-top:-15px">\n' +
        '                <div style="color: #909399;margin-top: 0">视频大小{{size}}MB以内</div>\n' +
        '                <div style="color: #909399;margin-top: -20px">支持类型：{{suffix}}</div>\n' +
        '            </div>\n' +
        '        </div>\n' +
        '    </div>\n' +
        '\n' +
        '    <div class="progress" v-if="uploadStatus && percentage > 0">\n' +
        '        <el-progress type="circle" :percentage="percentage" color=" var(--themeColors)"></el-progress>\n' +
        '    </div>\n' +
        '\n' +
        '    <div class="files" v-if="fileItems.url && !uploadStatus">\n' +
        '        <el-button  :disabled="disabled" class="Va-button button" size="mini" type="default" @click="fileUploadAgain">重新上传</el-button>\n' +
        '        <el-button  :disabled="disabled" class="Va-button button" size="mini" v-if="preview" type="default" @click="fileUploadPreview" style="top:42px">预览视频</el-button>\n' +
        '        <i class="el-icon-document icon"></i>\n' +
        '        <div class="text">\n' +
        '            <span class="text-space" style="font-weight: 500;font-size: 15px;line-height: 20px;display: inline-block;width: 90%;margin-top:10px">{{fileItems.original}}</span>\n' +
        '            <div style="font-size: 12px;margin-top: -20px">\n' +
        '                <div class="el-upload__tip" slot="tip" style="color: #909399">视频大小:{{fileItems.size}}字节</div>\n' +
        '            </div>\n' +
        '        </div>\n' +
        '    </div>\n' +
        '</div>',
    methods: {
        fileGalleryOpen: function () {
            var that = this;
            $Gallery.GalleryDialogOpen({
                max: 1,
                size: that.size,
                suffix: that.suffix,
                multiple: false,
                type: '2',
                tabs: false,
                callback: function (res) {
                    that.emitItemsEvent(res);
                    $App.$Message('视频上传成功！', 'success');
                    that.uploadStatus = false;
                    that.percentage = 0;
                }
            });
        },

        fileUploadPreview: function () {
            var that = this;
            $Preview.PreviewDialogOpen(that.fileItems.url);
        },

        fileUploadAgain: function () {
            var that = this;
            that.fileItems = {url: '', size: '', original: ''};
            that.emitItemsEvent({url: '', size: '', original: ''});
            that.uploadStatus = false;
            that.percentage = 0;
            if (that.onSuccess) {
                that.onSuccess();
            }
        },

        fileUploadProgress: function (event) {
            var that = this;
            that.percentage = parseFloat((event.percent).toFixed(2));
        },

        fileUploadSuccess: function (response, file, fileList) {
            var that = this;
            var _result = {url: '', original: '', size: '', code: 200};
            switch (that.uploadOption.driver) {
                case 'qiniu':
                    _result.url = that.uploadOption.domain + '/' + response.key;
                    _result.original = that._fileName;
                    _result.size = that._fileSize;
                    that.percentage = 0;
                    that.uploadStatus = false;
                    that.emitItemsEvent(_result);
                    if (that.onsuccess) {
                        that.onsuccess(_result);
                    }
                    $App.$Message('视频上传成功！', 'success');
                    break;
                case'oss':
                default:
                    if (response.code !== 200) {
                        that.percentage = 0;
                        that.uploadStatus = false;
                        $App.$Message(response.msg, 'warning');
                        return true;
                    } else {
                        that.percentage = 0;
                        that.uploadStatus = false;
                        that.emitItemsEvent(response.result);
                        if (that.onsuccess) {
                            that.onsuccess(response.result);
                        }
                        $App.$Message('视频上传成功！', 'success');
                        return true;
                    }
            }
        },

        fileUploadError: function () {
            var that = this;
            that.percentage = 0;
            that.uploadStatus = false;
            $App.$Message('视频上传失败，请重试！', 'warning');
            that.$refs.fileDialogUpload.clearFiles();
            return true;
        },

        fileUploadBefore: function (file, e) {
            var that = this;
            /*验证图片大小*/
            if (that.size) {
                if ((file.size / 1048576) > that.size) {
                    $App.$Message('请上传' + that.size + 'M以内的视频', 'warning');
                    that.$refs.fileDialogUpload.clearFiles();
                    return false;
                }
            }
            /*验证视频后缀*/
            if (that.suffix) {
                var args = ((file.name).split('.'));

                if (args[args.length - 1]) {
                    var suffix = (that.suffix).split(',');
                    if ($.inArray(args[args.length - 1], suffix) < 0) {
                        $App.$Message('请上传' + that.suffix + '类型的视频', 'warning');
                        that.$refs.fileDialogUpload.clearFiles();
                        return false;
                    }
                }
            }
            that._fileSize = (file.size / 1048576).toFixed(2);
            that._fileName = file.name;
            that.percentage = 1;
            that.uploadStatus = true;
            return true;
        },

        emitItemsEvent: function (value) {
            var that = this;
            that.fileItems = {
                url: value.url,
                size: value.size,
                original: value.original
            };
            that.UploadToken();
            that.$emit('change', JSON.stringify(that.fileItems));
        },
        UploadToken: function () {
            var that = this;
            if (that.gallery) return true;

            $Gallery.GalleryUploadToken(function (res) {
                that.uploadOption.driver = res.driver;
                that.uploadOption.domain = res.domain;
                that.action = res.action;
                that.postData.token = res.token;
                if (res.key) {
                    that.postData.key = res.key;
                }
                if (res.driver === 'local') {
                    that.action = 'framework/common/fileUploads';
                }
            }, 3);

        }
    },

    mounted: function () {
        var that = this;
        that.UploadToken();
        that.postData.size = that.size ? that.size : 20;
        that.postData.suffix = that.suffix ? that.suffix : 'doc,docx,xls,xlsx,xlsm,xlt,csv';
        if (that.file) {
            if ((typeof that.file) == 'object') {
                that.fileItems = that.file;
                that.$emit('change', JSON.stringify(that.fileItems));
            } else {
                if (!$Validator.json(that.file)) {
                    console.error('va-file components. File parameter requires a JSON string');
                } else {
                    that.fileItems = JSON.parse(that.file);
                    that.$emit('change', JSON.stringify(that.fileItems));
                }
            }
        } else {
            that.fileItems = {
                url: '',
                size: '',
                original: ''
            };
            that.$emit('change', JSON.stringify(that.fileItems));
        }
        that.uploadStatus = false;
        that.percentage = 0;
    }
});
Vue.component("va-file", {
    props: {
        action: {
            type: String,
            default: 'framework/common/fileUploads'
        },
        size: {
            type: Number,
            default: 20
        },
        suffix: {
            type: String,
            default: 'doc,docx,xls,xlsx,xlsm,xlt,csv'
        },
        postData: {
            type: Object,
            default: {
                size: 20,
                suffix: 'doc,docx,xls,xlsx,xlsm,xlt,csv'
            }
        },
        file: {
            type: String,
            default: "{url:'', size:'', original:''}"
        },
        gallery: {
            type: Boolean,
            default: true
        },
        preview: {
            type: Boolean,
            default: false
        },
        disabled: {
            type: String,
            default: false
        },
        onSuccess: {
            type: String,
            default: ''
        },
    },

    data: function () {
        return {
            postHeaders: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            uploadOption: {driver: 'local', domain: ''},
            uploadStatus: false,
            _fileName: '',
            _fileSize: 0,
            percentage: 0,
            fileItems: {url: '', size: '', original: ''},
            galleryOptions: {}
        }
    },

    model: {
        prop: 'file',
        event: 'change'
    },

    watch: {
        file(value) {
            if (!this.fileItems.url) {
                this.fileItems = JSON.parse(value);
                this.$emit('change', JSON.stringify(this.fileItems));
            }
        }
    },
    template: '<div class="va-component-file" :disabled="disabled">\n' +
        '    <el-upload\n' +
        '            v-if="!fileItems.url && !uploadStatus && !gallery"\n' +
        '            :action="action"\n' +
        '            :headers="postHeaders"\n' +
        '            limit="1"  drag\n' +
        '            :show-file-list="false"\n' +
        '            :data="postData"\n' +
        '            :disabled="disabled"\n' +
        '            :on-progress="fileUploadProgress"\n' +
        '            :on-success="fileUploadSuccess"\n' +
        '            :on-error="fileUploadError"\n' +
        '            :before-upload="fileUploadBefore"\n' +
        '            ref="fileDialogUpload"\n' +
        '    >\n' +
        '        <div class="upload">\n' +
        '            <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
        '            <div class="el-upload__text" style="margin-top: -12px">\n' +
        '                <el-link type="primary" :underline="false">\n' +
        '                    <span style="font-weight: 500;font-size: 15px">点击文件上传</span>\n' +
        '                </el-link>\n' +
        '                <div style="font-size: 12px;margin-top:-15px">\n' +
        '                    <div style="color: #909399;height: 15px">文件大小{{size}}MB以内</div>\n' +
        '                    <div style="color: #909399;height: 15px">支持类型：{{suffix}}</div>\n' +
        '                </div>\n' +
        '            </div>\n' +
        '        </div>\n' +
        '    </el-upload>\n' +
        '    <div class="upload" @click="fileGalleryOpen" v-if="!fileItems.url && !uploadStatus && gallery">\n' +
        '        <i class="el-icon-upload icon" :disabled="disabled"></i>\n' +
        '        <div class="el-upload__text" style="margin-top: -12px">\n' +
        '            <el-link type="primary" :disabled="disabled" :underline="false">\n' +
        '                <span style="font-weight: 500;font-size: 15px">点击文件上传</span>\n' +
        '            </el-link>\n' +
        '            <div style="font-size: 12px;margin-top:-15px">\n' +
        '                <div style="color: #909399;margin-top: 0">文件大小{{size}}MB以内</div>\n' +
        '                <div style="color: #909399;margin-top: -20px">支持类型：{{suffix}}</div>\n' +
        '            </div>\n' +
        '        </div>\n' +
        '    </div>\n' +
        '\n' +
        '    <div class="progress" v-if="uploadStatus && percentage > 0">\n' +
        '        <el-progress type="circle" :percentage="percentage" color=" var(--themeColors)"></el-progress>\n' +
        '    </div>\n' +
        '\n' +
        '    <div class="files" v-if="fileItems.url && !uploadStatus">\n' +
        '        <el-button  :disabled="disabled" class="Va-button button" size="mini" type="default" @click="fileUploadAgain">重新上传</el-button>\n' +
        '        <el-button  :disabled="disabled" class="Va-button button" size="mini" v-if="preview" type="default" @click="fileUploadPreview" style="top:42px">预览文件</el-button>\n' +
        '        <i class="el-icon-document icon"></i>\n' +
        '        <div class="text">\n' +
        '            <span style="font-weight: 500;font-size: 15px;line-height: 20px;display: inline-block;width: 90%;margin-top:10px">{{fileItems.original}}</span>\n' +
        '            <div style="font-size: 12px;margin-top: -20px">\n' +
        '                <div class="el-upload__tip" slot="tip" style="color: #909399">文件大小:{{fileItems.size}}字节</div>\n' +
        '            </div>\n' +
        '        </div>\n' +
        '    </div>\n' +
        '</div>',
    methods: {
        fileGalleryOpen: function () {
            var that = this;
            $Gallery.GalleryDialogOpen({
                max: 1,
                size: that.size,
                suffix: that.suffix,
                multiple: false,
                type: '3',
                tabs: false,
                callback: function (res) {
                    that.emitItemsEvent(res);
                    $App.$Message('文件上传成功！', 'success');
                    that.uploadStatus = false;
                    that.percentage = 0;
                }
            });
        },

        fileUploadPreview: function () {
            var that = this;
            $Preview.PreviewDialogOpen(that.fileItems.url);
        },

        fileUploadAgain: function () {
            var that = this;
            that.fileItems = {url: '', size: '', original: ''};
            that.emitItemsEvent({url: '', size: '', original: ''});
            that.uploadStatus = false;
            that.percentage = 0;
            if (that.onSuccess) {
                that.onSuccess();
            }
        },

        fileUploadProgress: function (event) {
            var that = this;
            that.percentage = parseFloat((event.percent).toFixed(2));
        },

        fileUploadSuccess: function (response, file, fileList) {
            var that = this;
            var _result = {url: '', original: '', size: '', code: 200};
            switch (that.uploadOption.driver) {
                case 'qiniu':
                    _result.url = that.uploadOption.domain + '/' + response.key;
                    _result.original = that._fileName;
                    _result.size = that._fileSize;
                    that.percentage = 0;
                    that.uploadStatus = false;
                    that.emitItemsEvent(_result);
                    if (that.onsuccess) {
                        that.onsuccess(_result);
                    }
                    $App.$Message('文件上传成功！', 'success');
                    break;
                case'oss':
                default:
                    if (response.code !== 200) {
                        that.percentage = 0;
                        that.uploadStatus = false;
                        $App.$Message(response.msg, 'warning');
                        return true;
                    } else {
                        that.percentage = 0;
                        that.uploadStatus = false;
                        that.emitItemsEvent(response.result);
                        if (that.onsuccess) {
                            that.onsuccess(response.result);
                        }
                        $App.$Message('文件上传成功！', 'success');
                        return true;
                    }
            }
        },

        fileUploadError: function () {
            var that = this;
            that.percentage = 0;
            that.uploadStatus = false;
            $App.$Message('文件上传失败，请重试！', 'warning');
            that.$refs.fileDialogUpload.clearFiles();
            return true;
        },

        fileUploadBefore: function (file, e) {
            var that = this;
            /*验证图片大小*/
            if (that.size) {
                if ((file.size / 1048576) > that.size) {
                    $App.$Message('请上传' + that.size + 'M以内的文件', 'warning');
                    that.$refs.fileDialogUpload.clearFiles();
                    return false;
                }
            }
            /*验证文件后缀*/
            if (that.suffix) {
                var args = ((file.name).split('.'));

                if (args[args.length - 1]) {
                    var suffix = (that.suffix).split(',');
                    if ($.inArray(args[args.length - 1], suffix) < 0) {
                        $App.$Message('请上传' + that.suffix + '类型的文件', 'warning');
                        that.$refs.fileDialogUpload.clearFiles();
                        return false;
                    }
                }
            }
            that._fileSize = (file.size / 1048576).toFixed(2);
            that._fileName = file.name;
            that.percentage = 1;
            that.uploadStatus = true;
            return true;
        },

        emitItemsEvent: function (value) {
            var that = this;
            that.fileItems = {
                url: value.url,
                size: value.size,
                original: value.original
            };
            that.UploadToken();
            that.$emit('change', JSON.stringify(that.fileItems));
        },
        UploadToken: function () {
            var that = this;
            if (that.gallery) return true;

            $Gallery.GalleryUploadToken(function (res) {
                that.uploadOption.driver = res.driver;
                that.uploadOption.domain = res.domain;
                that.action = res.action;
                that.postData.token = res.token;
                if (res.key) {
                    that.postData.key = res.key;
                }
                if (res.driver === 'local') {
                    that.action = 'framework/common/fileUploads';
                }
            }, 3);

        }
    },

    mounted: function () {
        var that = this;
        that.UploadToken();
        that.postData.size = that.size ? that.size : 20;
        that.postData.suffix = that.suffix ? that.suffix : 'doc,docx,xls,xlsx,xlsm,xlt,csv';
        if (that.file) {
            if ((typeof that.file) == 'object') {
                that.fileItems = that.file;
                that.$emit('change', JSON.stringify(that.fileItems));
            } else {
                if (!$Validator.json(that.file)) {
                    console.error('va-file components. File parameter requires a JSON string');
                } else {
                    that.fileItems = JSON.parse(that.file);
                    that.$emit('change', JSON.stringify(that.fileItems));
                }
            }
        } else {
            that.fileItems = {
                url: '',
                size: '',
                original: ''
            };
            that.$emit('change', JSON.stringify(that.fileItems));
        }
        that.uploadStatus = false;
        that.percentage = 0;
    }
});
/*弹窗时需要销毁 va-editor； 最好是同弹窗一起v-if*/
Vue.component("va-editor", {
    props: {
        height: {
            type: String,
            default: '200'
        },
        max_height: {
            type: String,
            default: '500'
        },
        id: {
            type: String,
            default: $Request.random(12)
        },
        placeholder: {
            type: String,
            default: '请填写内容'
        },
        disabled: {
            type: String,
            default: false
        },
        content: {
            type: String,
            default: ''
        },
        inline: {
            type: Boolean,
            default: false
        },
        toolbar: {
            type: String,
            default: '#fixed-editor-util'
        },
        mode: {
            type: String,
            default: 'ordinary'
        }, //simple, ordinary ,complex
        is_news: {
            type: String,
            default: '0'
        },
    },

    data: function () {
        return {
            vaEditorObj: {},
            reloadNum: 5,
        }
    },

    model: {
        prop: 'content',
        event: 'change'
    },

    watch: {
        content(value) {
            var that = this;
            // if (!that.vaEditorObj.getContent({
            //     format: 'text'
            // }) && value) {
            //     that.vaEditorObj.setContent(value);
            // }
            return true;
        },
    },
    template: '<div :id="id" class="va-editor tinymce-editor-ele" style="opacity: 0;width: 0;height: 0"></div>',
    methods: {
        createEditor: function () {
            var that = this;
            var plugins, toolbar = '';
            that.mode = that.mode ? that.mode : 'ordinary';
            switch (that.mode) {
                /*emoticons*/
                case 'simple':
                    plugins = 'print autosave preview searchreplace autolink directionality visualblocks visualchars fullscreen gallery image  link code codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern emoticons bdmap autoresize toolbarsticky';//media
                    toolbar = 'code undo redo | removeformat formats fontselect fontsizeselect bold italic underline  strikethrough hr blockquote forecolor backcolor  | gallery table  \
                  //| alignleft aligncenter alignright alignjustify outdent indent indent2em lineheight ';//image media imagetools
                    break;
                case 'ordinary':
                    plugins = 'print autosave preview searchreplace autolink directionality visualblocks visualchars fullscreen gallery image imagetools link code codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern emoticons bdmap autoresize toolbarsticky';//media
                    toolbar = 'code undo redo | removeformat formats fontselect fontsizeselect bold italic underline  strikethrough hr blockquote forecolor backcolor \
                  //| alignleft aligncenter alignright alignjustify outdent indent indent2em lineheight | gallery';//media
                    break;
                case 'complex':
                    plugins = '';
                    toolbar = '';
                    break;
            }
            $(function () {
                tinymce.init({
                    selector: '#' + that.id,
                    resize: true,
                    language: 'zh_CN',
                    menubar: that.mode === 'simple' ? false : ' file edit view table insert tool format image',
                    inline: that.inline,
                    font_formats: "微软雅黑='微软雅黑';宋体='宋体';黑体='黑体';仿宋='仿宋';楷体='楷体';隶书='隶书';幼圆='幼圆';Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings",
                    toolbar_groups: {
                        textformat: {
                            text: '文字格式',
                            icon: 'text-color',
                            tooltip: 'Formatting',
                            items: 'forecolor backcolor bold italic underline strikethrough',
                        },
                        paragraph: {
                            text: '段落',
                            icon: 'align-left',
                            tooltip: 'alignment',
                            items: 'alignleft aligncenter alignright alignjustify outdent indent indent2em lineheight',
                        },
                        alignments: {
                            text: '对齐方式',
                            icon: 'align-left',
                            tooltip: 'alignment',
                            items: 'alignleft aligncenter alignright alignjustify outdent indent indent2em lineheight ',
                        },
                    },
                    plugins: plugins,
                    toolbar: toolbar,
                    //                 plugins: 'print autosave preview searchreplace autolink directionality visualblocks visualchars fullscreen image media link code codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern emoticons bdmap autoresize ',//autosave
                    //                 toolbar: 'preview fullscreen code undo redo restoredraft  | textformat | paragraph | styleselect formatselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \
                    // table  emoticons hr  | powerpaste',
                    //                 plugins: 'print autosave preview searchreplace autolink directionality visualblocks visualchars fullscreen image media link code codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern emoticons bdmap autoresize ',//autosave
                    //                 toolbar: 'code undo redo restoredraft formatting | forecolor backcolor bold italic underline strikethrough | alignleft aligncenter alignright alignjustify outdent indent  | \
                    // styleselect formatselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \
                    // table  emoticons hr  | powerpaste',
                    imagetools_proxy: 'proxy.php',
                    placeholder: that.placeholder ? that.placeholder : '请输入内容',
                    readonly: that.disabled, //只读模式
                    branding: false, //隐藏右下角技术支持
                    statusbar: false,
                    elementpath: false, //隐藏底栏的元素路径
                    custom_undo_redo_levels: 30, //撤销次数
                    object_resizing: true, //调整大小控件开关
                    contextmenu_never_use_native: false, //在编辑器中屏蔽浏览器本身的右键菜单
                    fixed_toolbar_container: that.inline ? that.toolbar : '', // '#fixed-editor-util',//指定工具栏在某一容器顶部固定。
                    // fixed_toolbar_container: '#va-editor-content',//指定工具栏在某一容器顶部固定。
                    custom_ui_selector: 'body',
                    toolbar_mode: 'wrap',
                    // toolbar_sticky: true,
                    cfyun_toolbar_sticky: true,
                    toolbar_sticky_type: false,
                    toolbar_sticky_elem_height: 60,
                    toolbar_sticky_wrap: '.Va-container',

                    fontsize_formats: '12px 14px 16px 18px 24px 36px 48px 56px 72px',
                    remove_trailing_brs: true, //删除最尾的br
                    width: '100%',
                    min_height: parseInt(that.height),
                    autoresize_bottom_margin: 50, //自动调整编辑器大小的方法以适应内容
                    //autoresize_overflow_padding: 50,//指定编辑器body初始化时两侧的距离，相当于padding-left加padding-right
                    max_height: parseInt(that.max_height),
                    autolink: true, //autolink插件会自动创建超链接
                    fullscreen_native: true, //全屏将不在是网页全屏，而是使用浏览器的全屏模式
                    /*图片参数*/
                    image_uploadtab: false, //配置了images_upload_url后会在图像对话框中添加“上传”标签用于上传本地图像，此选项设false可关闭该标签。
                    image_advtab: false, //为图像属性编辑窗口添加高级属性
                    automatic_uploads: false, //Data URL/Blob URL插入图片和文件到内容区的方式
                    images_upload_credentials: false,
                    file_picker_types: 'media',// 上传类型 file_picker_types: 'image media',
                    // images_upload_url: 'framework/common/uploadEditor',
                    autosave_ask_before_unload: false, //当关闭或跳转URL时，弹出提示框提醒用户仍未保存变更内容。
                    autosave_interval: '5s', //自动存稿的世界间隔。注意该值为字符串，以秒为单位
                    convert_urls: false, //上传文件自动转换相对路径
                    image_caption: true, //在弹出框中增加一个“标题”选项，开启后图片将被包含在figure（HTML5新增）内。
                    image_description: true, //为img添加属性alt
                    typeahead_urls: true, //设false就是关闭地址input的自动完成。
                    media_alt_source: false, //显示隐藏资源备用地址输入框
                    media_poster: false, //显示隐藏图片封面输入框
                    media_live_embeds: true,
                    hidden_input: false,
                    visual: false,
                    inline_boundaries: false,
                    auto_focus: false,
                    setup: function (editor) {
                        that.vaEditorObj = editor;
                        editor.on('input change undo redo execCommand KeyUp', function (e) {
                            $(".el-container.is-vertical").css({
                                flexDirection: 'inherit'
                            });
                            $(".el-container.is-vertical").css({
                                flexDirection: 'column'
                            });
                            that.$emit('change', editor.getContent());
                        });
                        that.vaEditorObj.setMode(that.disabled ? 'readonly' : 'design');
                    },
                    init_instance_callback: function (editor) {
                        setTimeout(function () {
                            that.vaEditorObj.setContent(that.content);
                        }, 100);
                        //that.vaEditorObj.focus();
                    },

                    handle_event_callback: function (event) {
                        that.vaEditorObj.focus();
                    },
                    audio_template_callback: function (data) {
                        return '<audio controls>' + '\n<source src="' + data.source1 + '"' + (data.source1mime ? ' type="' + data.source1mime + '"' : '') + ' />\n' + '</audio>';
                    },
                    /*文件上传回调*/
                    file_picker_callback: function (callback, value, meta) {
                        window.galleryObj = {};
                        var fileParams = {
                            ts: meta.filetype,
                            ft: 1,
                            is_news: that.is_news,
                            mx: 1,
                            ck: 'ComponentPictureTemporaryEvent',
                            se: 20,
                        };
                        switch (meta.filetype) {
                            case "image":
                                fileParams.ft = 1;
                                fileParams.mx = 1;
                                fileParams.se = 20;
                                break;
                            case "media":
                                fileParams.ft = 2;
                                fileParams.mx = 1;
                                fileParams.se = 100;
                                break;
                            case "file":
                                fileParams.ft = 3;
                                fileParams.mx = 1;
                                fileParams.se = 100;
                                break;
                            default:
                                break;
                        }
                        $Gallery.GalleryDialogOpen({
                            max: fileParams.mx,
                            size: fileParams.se,
                            is_new: fileParams.is_news,
                            multiple: false,
                            type: fileParams.ft,
                            callback: function (res) {
                                callback(res.url, {
                                    source2: res.url,
                                    poster: res.original
                                });
                            }
                        });
                    },
                });
            });
            if (!that.vaEditorObj.id && that.reloadNum > 0) {
                setTimeout(function () {
                    that.createEditor();
                    that.reloadNum = that.reloadNum - 1;
                }, 500);
            }
        }
    },

    beforeDestroy: function () {
        tinymce.remove();
    },

    beforeCreate: function () {
    },

    created: function () {
        var that = this;
        setTimeout(function () {
            that.createEditor()
        }, 100);
    },

    mounted: function () {
    }
});
Vue.component('va-timer', {
    props: {
        time: {type: Number, default: 0},
    },
    data: function () {
        return {
            flag:null,
            hour:0,
            minute:0,
            second:0,
            hour_time:'00',
            minute_time:'00',
            second_time:'00',
        }
    },
    model: {
        prop: 'file',
        event: 'change'
    },
    template: '<div style="display: inline">' +
        '<span>{{hour_time}}</span>' +
        '<span>:</span>' +
        '<span>{{minute_time}}</span>' +
        '<span>:</span>' +
        '<span>{{second_time}}</span>' +
        '</div>',
    methods: {
        start(time){
            var that = this;

            if (time > 0){
                // 初始化时间
                var nowTime = Date.now()
                var date = new Date(parseInt(nowTime - (time * 1000)))
                that.hour = date.getUTCHours();
                that.minute = date.getUTCMinutes();
                that.second = date.getUTCSeconds();
            }

            // 开始定时
            that.flag = setInterval(()=>{
                that.second += 1;
                if(that.second >= 60){
                    that.second = 0;
                    that.minute += 1;
                }

                if (that.minute >= 60){
                    that.minute = 0;
                    that.hour += 1;
                }

                that.hour_time = that.zeroize(that.hour);
                that.minute_time = that.zeroize(that.minute);
                that.second_time = that.zeroize(that.second);
            },1000)
        },
        zeroize(n){
            return n < 10 ? '0' + n : "" + n;
        }
    },
    mounted: function() {
        var that = this;
        that.start(that.time);
    }
});
// Other
$(function () {
    // document.getElementsByClassName('el-drawer__container').onclick = function () {
    $('body').on('mousedown', '.el-drawer__container', function (e) {
        // $DrawerForms.methods.handleWrapperMousedown(e);
    })
    $('body').on('mouseup', '.el-drawer__container', function (e) {
        // $DrawerForms.methods.handleWrapperMouseup(e);
    })

    $('body').on('mousedown', '.el-dialog__wrapper', function (e) {
        // $DialogForms.methods.handleWrapperMousedown(e);
    })
    $('body').on('mouseup', '.el-dialog__wrapper', function (e) {
        // $DialogForms.methods.handleWrapperMouseup(e);
    })

    /**
     * panda
     * 页面加载进度条
     */
    if (location.hostname.match(/ricostacruz\.com$/)) {
        var _gaq = _gaq || [];
        _gaq.push(["_setAccount", "UA-20473929-1"]), _gaq.push(["_trackPageview"]), function () {
            var a = document.createElement("script");
            a.type = "text/javascript", a.async = !0, a.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
            var b = document.getElementsByTagName("script")[0];
            b.parentNode.insertBefore(a, b)
        }()
    }
    $('body').show();
    $('.version').text(NProgress.version);
    NProgress.start();
    setTimeout(function () {
        NProgress.done();
        $('.fade').removeClass('out');
    }, 1000);

    $("#b-0").click(function () {
        NProgress.start();
    });
    $("#b-40").click(function () {
        NProgress.set(0.4);
    });
    $("#b-inc").click(function () {
        NProgress.inc();
    });
    $("#b-100").click(function () {
        NProgress.done();
    });

    var HN = [];
    HN.factory = function (e) {
        return function () {
            HN.push([e].concat(Array.prototype.slice.call(arguments, 0)))
        };
    },
        HN.on = HN.factory("on"),
        HN.once = HN.factory("once"),
        HN.off = HN.factory("off"),
        HN.emit = HN.factory("emit"),
        HN.load = function () {
            var e = "hn-button.js";
            if (document.getElementById(e)) return;
            var t = document.createElement("script");
            //t.id=e,t.src="//hn-button.herokuapp.com/hn-button.js";
            var n = document.getElementsByTagName("script")[0];
            n.parentNode.insertBefore(t, n)
        }, HN.load();
    /**
     * panda
     * 页面加载进度条end.
     */
})

//表格关闭
function removeTableMoveEvent(obj) {
    $(obj).parent().removeClass('Va-table-move');
    $(obj).remove();
}

function in_array(val, arr) {
    for (var i = 0, len = arr.length; i < len; i++) {
        if (val === arr[i]) {
            return true;
        }
    }
    return false;
}

// 主题色
var themeStyle = {
    index: {
        themeColors: "#009688",
        themeTextColors: "#F9F9F9",
        themeSelectColors: "#606266",
        headerBackground: "#fff",
        headerTextColors: "#303133",
        leftBackground: "#344058",
        leftTextColors: "#fff",
        buttonHoverColors: "#009688"
    },
    purple: {
        themeColors: "#d21074",
        themeTextColors: "#F9F9F9",
        themeSelectColors: "#606266",
        headerBackground: "#fff",
        headerTextColors: "#303133",
        leftBackground: "#564d67",
        leftTextColors: "#fff",
        buttonHoverColors: "#d21074"
    },
    blue: {
        themeColors: "#2790a6",
        themeTextColors: "#F9F9F9",
        themeSelectColors: "#606266",
        headerBackground: "#fff",
        headerTextColors: "#303133",
        leftBackground: "#2d6973",
        leftTextColors: "#fff",
        buttonHoverColors: "#d21074"
    }
}